I am using the new Async driver and was wondering how to use it in conjunction with IAsyncEnumerable. Let's say I have 1million nodes and I want to stream them node by node, so it can be consumed by another methodA whenever this methodA is ready.
public async IAsyncEnumerable<IRecord> GetRecords()
{
var session = _neo4J.Driver.AsyncSession(o => o.WithDatabase("neo4j"));
try
{
var cursor = await session.RunAsync(
@"match (node:SomeNode)
return node");
//somehow yield return the records here?
}
catch (Exception e)
{
var error = e.ToString();
}
finally
{
await session.CloseAsync();
}
}
private void MethodA()
{
await foreach (var record in GetRecords())
{
// do something
}
}
What's the correct way to do this? Are there any async examples for the new 4.0 driver? What happens when the database nodes change while the execution is still in the for each loop?