Skip to content

Commit 3ae867f

Browse files
update source
1 parent fb68afc commit 3ae867f

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

src/shared/Z.EF.Plus.QueryFuture.Shared/BaseQueryFuture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,15 +428,15 @@ public virtual IRelationalCommand CreateExecutorAndGetCommand(out RelationalQuer
428428
}
429429
#elif EFCORE_3X
430430

431-
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
431+
//private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
432432

433-
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
433+
//private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
434434

435-
private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.First(x => x.Name == "_queryModelGenerator");
435+
//private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.First(x => x.Name == "_queryModelGenerator");
436436

437-
private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database");
437+
//private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database");
438438

439-
private static readonly PropertyInfo DatabaseDependenciesField = typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies");
439+
//private static readonly PropertyInfo DatabaseDependenciesField = typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies");
440440

441441
/// <summary>Creates executor and get command.</summary>
442442
/// <returns>The new executor and get command.</returns>

src/shared/Z.EF.Plus.QueryIncludeOptimized.Shared/QueryIncludeOptimizedByPath_EFCore.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ public static IQueryable<T> IncludeOptimizedByPath<T>(IQueryable<T> query, strin
2222
var elementType = typeof(T);
2323
var paths = navigationPath.Split('.');
2424

25-
var context = query.IsInMemoryQueryContext() ? null : query.GetDbContext();
25+
var queryForContext = query;
26+
27+
if (query is QueryIncludeOptimizedParentQueryable<T> queryIncludeOptimizedParent)
28+
{
29+
queryForContext = queryIncludeOptimizedParent.OriginalQueryable;
30+
}
31+
32+
var context = queryForContext.IsInMemoryQueryContext() ? null : queryForContext.GetDbContext();
2633

2734
// CREATE expression x => x.Right
2835
var expression = CreateLambdaExpression(elementType, paths, 0, context);
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Description: Entity Framework Bulk Operations & Utilities (EF Bulk SaveChanges, Insert, Update, Delete, Merge | LINQ Query Cache, Deferred, Filter, IncludeFilter, IncludeOptimize | Audit)
2+
// Website & Documentation: https://github.com/zzzprojects/Entity-Framework-Plus
3+
// Forum & Issues: https://github.com/zzzprojects/EntityFramework-Plus/issues
4+
// License: https://github.com/zzzprojects/EntityFramework-Plus/blob/master/LICENSE
5+
// More projects: http://www.zzzprojects.com/
6+
// Copyright © ZZZ Projects Inc. 2014 - 2016. All rights reserved.
7+
8+
9+
#if FULL || QUERY_INCLUDEOPTIMIZED
10+
#if EFCORE
11+
using System;
12+
using System.Reflection;
13+
using Microsoft.EntityFrameworkCore;
14+
15+
16+
namespace Z.EntityFramework.Plus
17+
{
18+
internal static partial class InternalExtensions
19+
{
20+
#if EFCORE_5X
21+
internal static string DisplayName(this Type type, bool fullName)
22+
{
23+
var displayNameMethod = typeof(DbContext).Assembly.GetType("System.SharedTypeExtensions").GetMethod("DisplayName");
24+
return (string)displayNameMethod.Invoke(null, new object[] {type, fullName });
25+
}
26+
#endif
27+
}
28+
}
29+
#endif
30+
#endif

src/shared/Z.EF.Plus._Core.Shared/Z.EF.Plus._Core.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<Compile Include="$(MSBuildThisFileDirectory)EFCore\IQueryable`\IQueryable`.GetCommand.cs" />
6262
<Compile Include="$(MSBuildThisFileDirectory)EFCore\IQueryable`\IsInMemoryQueryContext.cs" />
6363
<Compile Include="$(MSBuildThisFileDirectory)EFCore\LazyHelper.cs" />
64+
<Compile Include="$(MSBuildThisFileDirectory)EFCore\Type\DIsplayName.cs" />
6465
<Compile Include="$(MSBuildThisFileDirectory)EFCore\Type\GetTypeFromAssembly_Core.cs" />
6566
<Compile Include="$(MSBuildThisFileDirectory)EF\DbContext\DbContext.GetDbSetProperties.cs" />
6667
<Compile Include="$(MSBuildThisFileDirectory)EF\DbContext\DbContext.MapReader.cs" />

0 commit comments

Comments
 (0)