Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<List<string>> GetEstateTpyeById(string id)
- {
- List<string> result = null;
- var session = this._driver.AsyncSession();
- try
- {
- // Wrap whole operation into an managed transaction and
- // get the results back.
- result = await session.ReadTransactionAsync(async tx =>
- {
- var products = new List<string>();
- // Send cypher query to the database
- var cursor = await tx.RunAsync(
- "MATCH (type:EstateType) WHERE type.name = 'test' RETURN type", // Cypher query
- new { id } // Parameters in the query, if any
- );
- // Loop through the records asynchronously
- while (await cursor.FetchAsync())
- {
- // Each current read in buffer can be reached via Current
- // products.Add(cursor.Current[0].As<INode>().Properties.ToString()); // tried to cast it to estate type or smth
- products.Add(cursor.Current[0].ToString());
- }
- _logger.LogInformation("results length: " + products.Count);
- return products;
- });
- return result;
- }
- finally
- {
- // asynchronously close session
- await session.CloseAsync();
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement