Skip to content

Is returning an IAsyncEnumerable possible? #435

@cmaart

Description

@cmaart

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions