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.
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
SingleAsync(), etc. There are not async versions of LINQ operators such as
OrderBy(...), etc. because these methods only build up the LINQ expression tree and do not cause the query to be executed in the database.
- Filtering a collection by an async result, built an extension method called WhereAsync.
Running LINQ to SQL query async
- Wrap with a task,