EntityFramework-Plus icon indicating copy to clipboard operation
EntityFramework-Plus copied to clipboard

No Async Version for `EF Query Future`?

Open yyjdelete opened this issue 9 years ago • 6 comments

yyjdelete avatar Jun 06 '16 07:06 yyjdelete

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).

zzzprojects avatar Jun 06 '16 18:06 zzzprojects

:+1:

GFoley83 avatar Aug 08 '16 06:08 GFoley83

Added this feature to milestone 2.0

zzzprojects avatar Aug 21 '16 15:08 zzzprojects

I implemented a version of ToListAsync and ValueAsync for EF6.

https://github.com/mattmaslin/EntityFramework-Plus/commit/8c780c906300d9d2991748107821a7b4de2c0b27

mattmaslin avatar Aug 24 '16 14:08 mattmaslin

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.

panoskj avatar Nov 17 '21 06:11 panoskj

Hello @panoskj ,

Sure go ahead, I just put the code up to date.

Let me know if something is missing.

Best Regards,

Jon

JonathanMagnan avatar Nov 17 '21 13:11 JonathanMagnan