It is not quite clear how actually get results of the query from IQueryResults.
Use case:
I am passing sting NQ1L query that successfully executes:
var cluster = _clusterHelper.GetCluster().Result;
var result = await cluster.QueryAsync<List<ShotData>>(query);
I am getting Task<IQueryResult<List>>.
How do I actually get List from IQueryResult?
Thank you
If you want a list, then:
var result = await cluster.QueryAsync<List<ShotData>>(query);
var list = await result.ToListAsync();
On the other hand, if you want to simply enumerate you can get better performance and memory utilization via async enumeration:
// Works out of the box if targeting .NET Core 3.x
// Otherwise, turn on C# 8 via <LangVersion>8</LangVersion> in your project file
await foreach (var item in result)
{
// ...
}
More info about async enumeration: https://btburnett.com/csharp/2019/12/01/iasyncenumerable-is-your-friend.html
2 Likes