-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves#615 Resolves#1636 Resolves#1648 Resolves#1699 Resolves#1777
- Loading branch information
Showing
15 changed files
with
358 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
--- | ||
title: Asynchronous Queries - EF Core | ||
author: rowanmiller | ||
ms.date: 01/24/2017 | ||
author: smitpatel | ||
ms.date: 10/03/2019 | ||
ms.assetid: b6429b14-cba0-4af4-878f-b829777c89cb | ||
uid: core/querying/async | ||
--- | ||
|
||
# Asynchronous Queries | ||
|
||
Asynchronous queries avoid blocking a thread while the query is executed in the database. This can be useful to avoid freezing the UI of a thick-client application. Asynchronous operations can also increase throughput in a web application, where the thread can be freed up to service other requests while the database operation completes. For more information, see [Asynchronous Programming in C#](https://docs.microsoft.com/dotnet/csharp/async). | ||
Asynchronous queries avoid blocking a thread while the query is executed in the database. Async queries are important for keeping a responsive UI in thick-client applications. They can also increase throughput in web applications where they free up the thread to service other requests in web applications. For more information, see [Asynchronous Programming in C#](/dotnet/csharp/async). | ||
|
||
> [!WARNING] | ||
> EF Core does not support multiple parallel operations being run on the same context instance. You should always wait for an operation to complete before beginning the next operation. This is typically done by using the `await` keyword on each asynchronous operation. | ||
> EF Core doesn't support multiple parallel operations being run on the same context instance. You should always wait for an operation to complete before beginning the next operation. This is typically done by using the `await` keyword on each async operation. | ||
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. | ||
Entity Framework Core provides a set of async extension methods similar to the LINQ methods, which execute a query and return results. Examples include `ToListAsync()`, `ToArrayAsync()`, `SingleAsync()`. There are no async versions of some LINQ operators such as `Where(...)`, `OrderBy(...)`, because these methods only build up the LINQ expression tree and don't cause the query to be executed in the database. | ||
|
||
> [!IMPORTANT] | ||
> The EF Core async extension methods are defined in the `Microsoft.EntityFrameworkCore` namespace. This namespace must be imported for the methods to be available. | ||
[!code-csharp[Main](../../../samples/core/Querying/Async/Sample.cs#Sample)] | ||
[!code-csharp[Main](../../../samples/core/Querying/Async/Sample.cs#ToListAsync)] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.