Reputation: 11401
I have a query that results in a 300 - 500 result set. I know it's not many items but it does take a long time to compute, something like 60 to 90 sec...
When I run the query generated by EF6 on Management studio I get 2-3 new rows each second.
I would like to replicate this behavior in my grid, eg: feed the grid new rows as they become available.
Is there a way to do this using EF6?
Using the "async" keyword/method forces the whole operation to hang... I used to do this using BeginExecuteReader + callback and some settings on SqlConnection...
Upvotes: 1
Views: 900
Reputation: 21207
There doesn't seem to be a lot of documentation about it but it appears that Entity Framework 6 added the ForEachAsync extensions method:
Code example found on this blog
using (var context = new DataContext()) {
await context.Manufacturers.ForEachAsync(m => Console.WriteLine("{0} : {1}", m.Name, m.Country));
}
In your item callback you could just send the results back to the UI as they become available.
Upvotes: 2