dotnet / dotnet/EntityFramework.Docs

How do I async foreach??

Open
#4,338 0 comments 0 reactions 0 assignees View on GitHub
area-query
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

I'm ashamed to say that I had to look this up. (+1 for https://github.com/dotnet/efcore/issues/28103 BTW) I'm even more ashamed at how hard it was to find the answer.

```cs
var blogs = context.Blogs.Where(b => b.Rating > 3);

await foreach (var blog in blogs.AsAsyncEnumerable())
{
// ...
}
```

---
#### Document Details

⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*

* ID: b68ae31d-b942-507a-2b9f-c8f7632ff283
* Version Independent ID: 0574f1d2-3620-c6b6-94b8-99a455a67a5a
* Content: [Asynchronous Programming - EF Core](https://learn.microsoft.com/en-us/ef/core/miscellaneous/async)
* Content Source: [entity-framework/core/miscellaneous/async.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/miscellaneous/async.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @roji
* Microsoft Alias: **avickers**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.