zzzprojects / EntityFramework-Plus

Entity Framework Plus extends your DbContext with must-haves features: Include Filter, Auditing, Caching, Query Future, Batch Delete, Batch Update, and more
https://entityframework-plus.net/
MIT License
2.24k stars 318 forks source link

EF+ | Query Future | InMemory Provider #102

Open zzzprojects opened 7 years ago

zzzprojects commented 7 years ago

Issue from #86

Currently investigating this issue due to unit testing. My thought is that you are perhaps over-complicating it.

Batching of future transactions helps on round trips to database servers. Particularly important when that db server is not on the same machine. In Memory is always local. (as far as i know) And its fast... It is also not relational. So for InMemory, bypass batching. Short Circuit the issue. At a high level check for in memory and bypass all the batching logic. Just let the call happen normally for EFCore.

ksmithRenweb commented 7 years ago

Hi,

When can we expect this to be fixed?

Thanks, Kevin

JonathanMagnan commented 7 years ago

Hello @ksmithRenweb ,

Thank you for the reminder.

The v1.4.24 is now available which now support InMemory provider for Query Future.

Let me know if it's working.

Best Regards,

Jonathan

ksmithRenweb commented 7 years ago

Update. For the most part your fix seems to work. We've had one bug report related to the In Memory Provider issue though.

The bug is in this code: Context.Table.Where(x => x.That = this).Update(y => new Item{Points = points});

This is the stacktrace. <System.InvalidCastException: Unable to cast object of type 'Microsoft.EntityFrameworkCore.Query.Internal.InMemoryQueryContextFactory' to type 'Microsoft.EntityFrameworkCore.Query.Internal.RelationalQueryContextFactory'. at Z.EntityFramework.Plus.InternalExtensions.GetDbContext[T](IQueryable1 source) at Z.EntityFramework.Plus.BatchUpdate.Execute[T](IQueryable1 query, Expression`1 updateFactory) at LessonManagementService.Repository.QuizRepository.Add(WebTestQuestion webTestQuestion) in C:\repos\renweb-backendservice\ManagementService\LessonManagementService\Repository\QuizRepository.cs:line 155 at LessonManagement.Tests.Service.Repository.QuizRepositoryTests.<>cDisplayClass7_0.b1() in C:\repos\renweb-backendservice\Tests\LessonManagement.Tests\Service\Repository\QuizRepositoryTests.cs:line 181 at NUnit.Framework.Constraints.ThrowsConstraint.VoidInvocationDescriptor.Invoke() at NUnit.Framework.Constraints.ThrowsConstraint.ExceptionInterceptor.Intercept(Object invocation)>

at LessonManagement.Tests.Service.Repository.QuizRepositoryTests.LM_QuizRepository_Add_1() in C:\repos\renweb-backendservice\Tests\LessonManagement.Tests\Service\Repository\QuizRepositoryTests.cs:line 181

ksmithRenweb commented 7 years ago

Setting it to UpdateAsync works...