It's a Lambda expression thingy. You can do it off of an IQueryable holding a collection.
await myCollection.ForEachAsync(mc =>
{
stupidCounter = stupidCounter + mc.Id;
});
There is also a ToListAsync and the way you use it is to do a .ToListAsync() on the end of the thing that makes your IQueryable. Your IQueryable thus must become a List and later on when you do a foreach it can just be a regular foreach loop instead of the ForEachAsync trick. You will need the await keyword after the equals sign too so that the overall assignment starts out like so:
List<Aardvark> myCollection = await ...
No comments:
Post a Comment