Skip to content

Commit 132097a

Browse files
update source
1 parent 32f8342 commit 132097a

File tree

7 files changed

+67
-4
lines changed

7 files changed

+67
-4
lines changed
0 Bytes
Binary file not shown.

src/.vs/Z.EntityFramework.Plus/project-colors.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,42 @@
55
"ProjectGuid": "a2fe74e1-b743-11d0-ae1a-00a0c90fffc3",
66
"DisplayName": "Miscellaneous Files",
77
"ColorIndex": -1
8+
},
9+
"1b28efb7-e679-4275-aca9-da7cd589a56a": {
10+
"ProjectGuid": "1b28efb7-e679-4275-aca9-da7cd589a56a",
11+
"DisplayName": "Z.EntityFramework.Plus.EF5",
12+
"ColorIndex": 0
13+
},
14+
"e4c2af73-caeb-4429-bcb6-0a359484e064": {
15+
"ProjectGuid": "e4c2af73-caeb-4429-bcb6-0a359484e064",
16+
"DisplayName": "Z.EntityFramework.Plus.EF5.NET40",
17+
"ColorIndex": 1
18+
},
19+
"6ea3675a-ab66-4aba-94d1-3da69fa88d4e": {
20+
"ProjectGuid": "6ea3675a-ab66-4aba-94d1-3da69fa88d4e",
21+
"DisplayName": "Z.EntityFramework.Plus.EF6",
22+
"ColorIndex": 2
23+
},
24+
"ac398eb8-0a31-4d06-a804-84d10b6da96d": {
25+
"ProjectGuid": "ac398eb8-0a31-4d06-a804-84d10b6da96d",
26+
"DisplayName": "Z.EntityFramework.Plus.EF6.NET40",
27+
"ColorIndex": 3
28+
},
29+
"ef1cbe03-3b93-4f28-8d98-3166320f62db": {
30+
"ProjectGuid": "ef1cbe03-3b93-4f28-8d98-3166320f62db",
31+
"DisplayName": "Z.EntityFramework.Plus.EFCore.NETStandard20",
32+
"ColorIndex": 4
33+
},
34+
"61add154-ff1b-4683-80c9-ec6468a84c36": {
35+
"ProjectGuid": "61add154-ff1b-4683-80c9-ec6468a84c36",
36+
"DisplayName": "Z.EntityFramework.Plus.EFCore3x.NETStandard20",
37+
"ColorIndex": 5
38+
},
39+
"d7434620-9c01-4260-9c84-4574b3e2827a": {
40+
"ProjectGuid": "d7434620-9c01-4260-9c84-4574b3e2827a",
41+
"DisplayName": "Z.EntityFramework.Plus.EFCore3x.NETStandard21",
42+
"ColorIndex": 6
843
}
944
},
10-
"NextColorIndex": 0
45+
"NextColorIndex": 7
1146
}
0 Bytes
Binary file not shown.

src/shared/Z.EF.Plus.QueryFilterInterceptor.Shared/QueryFilterInterceptorManager.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,29 @@ public static void ForceAlwaysEmptyQueryCacheManager(DbContext context)
262262
public static void ClearAllCache()
263263
{
264264
var propertyValues = CacheWeakFilterContext.GetType().GetProperty("Values", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
265-
var values = (List<QueryFilterContextInterceptor>) propertyValues.GetValue(CacheWeakFilterContext, null);
265+
266+
if(propertyValues != null)
267+
{
268+
var values = (List<QueryFilterContextInterceptor>)propertyValues.GetValue(CacheWeakFilterContext, null);
266269

267-
foreach (var value in values)
270+
foreach (var value in values)
271+
{
272+
value.ClearCache();
273+
}
274+
}
275+
#if NETSTANDARD2_1
276+
// Only do it when propertyValues is null for backward compatibility
277+
else
268278
{
269-
value.ClearCache();
279+
var keyValues = CacheWeakFilterContext.ToList();
280+
var values = keyValues.Select(x => x.Value).ToList();
281+
282+
foreach (var value in values)
283+
{
284+
value.ClearCache();
285+
}
270286
}
287+
#endif
271288
}
272289

273290
/// <summary>Clears the global filter.</summary>

src/shared/Z.EF.Plus._Core.Shared/EFCore/IQueryable`/GetDbContext.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ internal static partial class InternalExtensions
2121
{
2222
public static DbContext GetDbContext<T>(this IQueryable<T> source)
2323
{
24+
#if EFCORE
25+
source = Z.EntityFramework.Extensions.PublicExtensions.GetInnerForLinqKit(source);
26+
#endif
2427
var compilerField = typeof (EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance);
2528
var compiler = (QueryCompiler) compilerField.GetValue(source.Provider);
2629

@@ -88,6 +91,10 @@ public static DbContext GetDbContext<T>(this IQueryable<T> source)
8891
/// <returns>The database context from the query.</returns>
8992
public static DbContext GetDbContext(this IQueryable query)
9093
{
94+
#if EFCORE
95+
query = Z.EntityFramework.Extensions.PublicExtensions.GetInnerForLinqKit(query);
96+
#endif
97+
9198
var compilerField = typeof (EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance);
9299
var compiler = (QueryCompiler) compilerField.GetValue(query.Provider);
93100

src/shared/Z.EF.Plus._Core.Shared/EFCore/IQueryable`/GetInMemoryContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ internal static partial class InternalExtensions
2020
{
2121
public static DbContext GetInMemoryContext<T>(this IQueryable<T> source)
2222
{
23+
source = Z.EntityFramework.Extensions.PublicExtensions.GetInnerForLinqKit(source);
24+
2325
var compilerField = typeof(EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance);
2426
var compiler = (QueryCompiler)compilerField.GetValue(source.Provider);
2527

src/shared/Z.EF.Plus._Core.Shared/EFCore/IQueryable`/IsInMemoryQueryContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ internal static partial class InternalExtensions
3131
{
3232
public static bool IsInMemoryQueryContext<T>(this IQueryable<T> query)
3333
{
34+
query = Z.EntityFramework.Extensions.PublicExtensions.GetInnerForLinqKit(query);
35+
3436
var compilerField = typeof(EntityQueryProvider).GetField("_queryCompiler", BindingFlags.NonPublic | BindingFlags.Instance);
3537
var compiler = (QueryCompiler)compilerField.GetValue(query.Provider);
3638

0 commit comments

Comments
 (0)