DotNet4Neo4j / Neo4jClient

.NET client binding for Neo4j
https://www.nuget.org/packages/Neo4jClient
Microsoft Public License
431 stars 146 forks source link

Is returning an IAsyncEnumerable possible? #435

Open cmaart opened 2 years ago

cmaart commented 2 years ago

Hi,

I'd like to return an IAsyncEnumerable from a method using CypherFluentQuery, is that possible?

That's how far I am with this:

var cypherFluentQuery = _client.Cypher
  ...CypherQuery Magic here...
  .Return(() => new {
      ...
  });

await using var session = _driver.AsyncSession();

IResultCursor? cursor = await session.Run(cypherFluentQuery.Query, _client);

while (await cursor.FetchAsync())
{
  IRecord record = cursor.Current;

 // Now how to parse IRecord to T (my class, let's stay Student class)?

 yield return (Student) record;

}

But I'm stuck deserializing the record from session.Run to my class. StatementResultHelper might be helpful for that, but it's internal. Is there any other way to reach through neo4jclient to get IResultCursor or something different to be able to return as IAsyncEnumerable

Thanks for any help :)