IncludeOptimized and Cache don't work together.
Description
var projects = dbContext.Projects
.IncludeOptimized(x => x.Sites)
.FromCache("projects");
//schematic model:
class Projects {
List<Site> Sites;
}
class Site {
Guid SiteID;
Guid ProjectID;
Project Project;
}
Exception
Exception message: Field '_queryCompiler' defined on type 'Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider' is not a field on the target object which is of type 'Z.EntityFramework.Plus.QueryIncludeOptimizedProvider`1[DBModel.Project]'.
Stack trace: at System.Reflection.RtFieldInfo.GetValue(Object obj) in /_/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs:line 178
at .(IQueryable , RelationalQueryContext& , QuerySqlGenerator& )
at Z.EntityFramework.Plus.QueryCacheManager.GetCacheKey(IQueryable query, String[] tags)
at Z.EntityFramework.Plus.QueryCacheExtensions.FromCache[T](IQueryable`1 query, MemoryCacheEntryOptions options, String[] tags)
at Z.EntityFramework.Plus.QueryCacheExtensions.FromCache[T](IQueryable`1 query, String[] tags)
Further technical details
- EF version: 3.1
- EF Plus version: 3.0.60
- Database Provider: MSSQLServer
Hello @gizadirov ,
Thank you for reporting, we successfully reproduced the issue.
We will look if we can make both features work together.
Best Regards,
Jon
Performance Libraries
context.BulkInsert(list, options => options.BatchSize = 1000);
Entity Framework Extensions • Entity Framework Classic • Bulk Operations • Dapper Plus
Runtime Evaluation
Eval.Execute("x + y", new {x = 1, y = 2}); // return 3
C# Eval Function • SQL Eval Function
Hello @gizadirov ,
We tried to make it work but unfortunately, the IncludeOptimized requires a ChangeTracker to work correctly and the Cache feature requires to don't use a ChangeTracker since entities returned cannot be dependent from a Context.
So at this moment, there is nothing we can do for it ;(
Best Regards,
Jon