Posts

Showing posts from April, 2019

Entity Framework: ToListAynsc & WhereAsync

When upgrading aspnet mvc applications I like to take a look on how I can convert the api's to async. This sometimes is really easy but as things get more complex my queries do as well. So this is a list of ways you can form a where clause on top your async but note not all solutions take advantage of it.
Notes on EFCore Entity Framework Core provides a set of asynchronous extension methods that can be used as an alternative to the LINQ methods that cause a query to be executed and results returned. Examples include ToListAsync(), ToArrayAsync(), SingleAsync(), etc. There are not async versions of LINQ operators such as Where(...), OrderBy(...), etc. because these methods only build up the LINQ expression tree and do not cause the query to be executed in the database. https://codereview.stackexchange.com/questions/32160/filtering-a-collection-by-an-async-resultFiltering a collection by an async result, built an extension method called WhereAsync.publicstatic async Task<IEnumerable…