EntityFramework-Plus
EntityFramework-Plus copied to clipboard
No Async Version for `EF Query Future`?
Hello,
You are right, and this is not possible at this moment. The “Future” method return an IEnumerable, and async method requires IQueryable.
We will check the possibilities of this features later this week. (We are currently trying to complete the migration of EF+ for EFCore from RC1 to RC2 which makes it hard to perform some test on features at this moment).
:+1:
Added this feature to milestone 2.0
I implemented a version of ToListAsync and ValueAsync for EF6.
https://github.com/mattmaslin/EntityFramework-Plus/commit/8c780c906300d9d2991748107821a7b4de2c0b27
Hello, this implementation is still not async. Specifically, it calls BaseQueryFuture.GetResultDirectly and BaseQueryFuture.SetResult.
GetResultDirectly will be called when there is only one query in the batch (and when running in-memory, but this is irrelevant).
SetResult is the method that actually enumerates the rows and turns them into a list. This part may wait for potentially lots of data to be received over the network and this is done synchronously now.
I am aware of the bug with large columns and async that you mention in #131, but it should be up to the user to choose. Naming the method ToListAsync while it runs most of the work synchronously is misleading. For your info, there is a way to fix the async bug (intercepting EF DBDataReader creation and replacing it with a fixed version).
I can make a pull request that makes ToListAsync and ValueAsync truly async, as I understand you could use some help.
I can also share the code for fixing the async bug if you are interested. I think it would fit in your library as an optionally enabled feature.
Hello @panoskj ,
Sure go ahead, I just put the code up to date.
Let me know if something is missing.
Best Regards,
Jon