S7s
❔ How do IAsyncEnumerable gets the data from the database
Do you know if IAsyncEnumerable loads all the data from the database before streaming it to the application, or does it directly retrieve a stream of data record by record from the database itself?
I am a bit uncertain about this particular scenario. Here's an example:
public class MyEntity
{
public int Id { get; set; }
public string Name { get; set; }
}
await foreach (var entity in dbContext.MyEntities.AsAsyncEnumerable())
{
Console.WriteLine($"Id: {entity.Id}, Name: {entity.Name}");
}
5 replies