Skip to content

Commit ae0558d

Browse files
Update GitHub with latest source
Update GitHub with latest source
1 parent 544ade2 commit ae0558d

File tree

47 files changed

+763
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+763
-191
lines changed

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#elif EF6
1717
using System.Data.Entity;
18+
using System.Data.Entity.Core.Objects;
1819

1920
#elif EFCORE
2021
using Microsoft.EntityFrameworkCore;
@@ -34,6 +35,12 @@ public AuditConfiguration()
3435

3536
EntityValueFormatters = new List<Func<object, string, object, Func<object, object>>>();
3637
ExcludeIncludeEntityPredicates = new List<Func<object, bool?>>();
38+
#if EF5 || EF6
39+
ExcludeIncludeByInstanceEntityPredicates = new List<Func<ObjectStateEntry, bool?>>();
40+
#elif EFCORE
41+
ExcludeIncludeByInstanceEntityPredicates = new List<Func<EntityEntry, bool?>>();
42+
#endif
43+
3744
ExcludeIncludePropertyPredicates = new List<Func<object, string, bool?>>();
3845

3946
SoftAddedPredicates = new List<Func<object, bool>>();
@@ -72,6 +79,14 @@ public AuditConfiguration()
7279
/// <value>A list of predicates to exclude or include entities.</value>
7380
public List<Func<object, bool?>> ExcludeIncludeEntityPredicates { get; set; }
7481

82+
/// <summary>Gets or sets a list of predicates to exclude or include by instance entities.</summary>
83+
/// <value>A list of predicates to exclude or include by instance entities.</value>
84+
#if EF5 || EF6
85+
public List<Func<ObjectStateEntry, bool?>> ExcludeIncludeByInstanceEntityPredicates { get; set; }
86+
#elif EFCORE
87+
public List<Func<EntityEntry, bool?>> ExcludeIncludeByInstanceEntityPredicates { get; set; }
88+
#endif
89+
7590
/// <summary>Gets or sets a list of predicates to exclude or include properties.</summary>
7691
/// <value>A list of predicates to exclude or include properties.</value>
7792
public List<Func<object, string, bool?>> ExcludeIncludePropertyPredicates { get; set; }
@@ -179,6 +194,11 @@ public AuditConfiguration Clone()
179194
IgnoreRelationshipDeleted = IgnoreRelationshipDeleted,
180195
EntityValueFormatters = new List<Func<object, string, object, Func<object, object>>>(EntityValueFormatters),
181196
ExcludeIncludeEntityPredicates = new List<Func<object, bool?>>(ExcludeIncludeEntityPredicates),
197+
#if EF5 || EF6
198+
ExcludeIncludeByInstanceEntityPredicates = new List<Func<ObjectStateEntry, bool?>>(ExcludeIncludeByInstanceEntityPredicates),
199+
#elif EFCORE
200+
ExcludeIncludeByInstanceEntityPredicates = new List<Func<EntityEntry, bool?>>(ExcludeIncludeByInstanceEntityPredicates),
201+
#endif
182202
ExcludeIncludePropertyPredicates = new List<Func<object, string, bool?>>(ExcludeIncludePropertyPredicates),
183203
SoftAddedPredicates = new List<Func<object, bool>>(SoftAddedPredicates),
184204
SoftDeletedPredicates = new List<Func<object, bool>>(SoftDeletedPredicates),
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
using System;
9+
10+
#if EF5
11+
using System.Data.Entity;
12+
using System.Data.Objects;
13+
14+
#elif EF6
15+
using System.Data.Entity;
16+
using System.Data.Entity.Core.Objects;
17+
18+
#elif EFCORE
19+
using Microsoft.EntityFrameworkCore;
20+
using Microsoft.EntityFrameworkCore.ChangeTracking;
21+
22+
#endif
23+
24+
namespace Z.EntityFramework.Plus
25+
{
26+
public partial class AuditConfiguration
27+
{
28+
/// <summary>Excludes (by entity entry) from the audit all entities which satisfy the predicate.</summary>
29+
/// <param name="excludeEntityPredicate">The exclude entity predicate.</param>
30+
/// <returns>An AuditConfiguration.</returns>
31+
#if EF5 || EF6
32+
public AuditConfiguration ExcludeByEntry(Func<ObjectStateEntry, bool> excludeEntityPredicate)
33+
#elif EFCORE
34+
public AuditConfiguration ExcludeByEntry(Func<EntityEntry, bool> excludeEntityPredicate)
35+
#endif
36+
37+
{
38+
ExcludeIncludeByInstanceEntityPredicates.Add(x => excludeEntityPredicate(x) ? (bool?) false : null);
39+
return this;
40+
}
41+
}
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
using System;
9+
10+
namespace Z.EntityFramework.Plus
11+
{
12+
public partial class AuditConfiguration
13+
{
14+
/// <summary>Excludes (by entity instance) from the audit all entities which satisfy the predicate.</summary>
15+
/// <param name="excludeEntityPredicate">The exclude entity predicate.</param>
16+
/// <returns>An AuditConfiguration.</returns>
17+
public AuditConfiguration ExcludeByInstance(Func<object, bool> excludeEntityPredicate)
18+
{
19+
ExcludeIncludeByInstanceEntityPredicates.Add(x => excludeEntityPredicate(x.Entity) ? (bool?)false : null);
20+
return this;
21+
}
22+
}
23+
}

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration/ExcludeEntity.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ namespace Z.EntityFramework.Plus
1111
{
1212
public partial class AuditConfiguration
1313
{
14-
/// <summary>Excludes from the audit all entities which satisfy the predicate.</summary>
14+
15+
/// <summary>Excludes (by entity type) from the audit all entities which satisfy the predicate.</summary>
1516
/// <param name="excludeEntityPredicate">The exclude entity predicate.</param>
1617
/// <returns>An AuditConfiguration.</returns>
1718
public AuditConfiguration Exclude(Func<object, bool> excludeEntityPredicate)
@@ -20,7 +21,7 @@ public AuditConfiguration Exclude(Func<object, bool> excludeEntityPredicate)
2021
return this;
2122
}
2223

23-
/// <summary>Excludes from the audit all entities of 'T' type or entities which the type derive from 'T'.</summary>
24+
/// <summary>Excludes (by entity type) from the audit all entities of 'T' type or entities which the type derive from 'T'.</summary>
2425
/// <typeparam name="T">Generic type to exclude.</typeparam>
2526
/// <returns>An AuditConfiguration.</returns>
2627
public AuditConfiguration Exclude<T>()
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
using System;
9+
10+
#if EF5
11+
using System.Data.Entity;
12+
using System.Data.Objects;
13+
14+
#elif EF6
15+
using System.Data.Entity;
16+
using System.Data.Entity.Core.Objects;
17+
18+
#elif EFCORE
19+
using Microsoft.EntityFrameworkCore;
20+
using Microsoft.EntityFrameworkCore.ChangeTracking;
21+
22+
#endif
23+
24+
namespace Z.EntityFramework.Plus
25+
{
26+
public partial class AuditConfiguration
27+
{
28+
/// <summary>Includes (by entity entry) from the audit all entities which satisfy the predicate.</summary>
29+
/// <param name="includeEntityPredicate">The include entity predicate.</param>
30+
/// <returns>An AuditConfiguration.</returns>
31+
#if EF5 || EF6
32+
public AuditConfiguration IncludeByEntry(Func<ObjectStateEntry, bool> includeEntityPredicate)
33+
#elif EFCORE
34+
public AuditConfiguration IncludeByEntry(Func<EntityEntry, bool> includeEntityPredicate)
35+
#endif
36+
37+
{
38+
ExcludeIncludeByInstanceEntityPredicates.Add(x => includeEntityPredicate(x) ? (bool?)true : null);
39+
return this;
40+
}
41+
}
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
using System;
9+
10+
namespace Z.EntityFramework.Plus
11+
{
12+
public partial class AuditConfiguration
13+
{
14+
/// <summary>Includes (by entity instance) from the audit all entities which satisfy the predicate.</summary>
15+
/// <param name="includeEntityPredicate">The include entity predicate.</param>
16+
/// <returns>An AuditConfiguration.</returns>
17+
public AuditConfiguration IncludeByInstance(Func<object, bool> includeEntityPredicate)
18+
{
19+
ExcludeIncludeByInstanceEntityPredicates.Add(x => includeEntityPredicate(x.Entity) ? (bool?) true : null);
20+
return this;
21+
}
22+
}
23+
}

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration/IncludeEntity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Z.EntityFramework.Plus
1111
{
1212
public partial class AuditConfiguration
1313
{
14-
/// <summary>Includes from the audit all entities which satisfy the predicate.</summary>
14+
/// <summary>Includes (by entity type) from the audit all entities which satisfy the predicate.</summary>
1515
/// <param name="includeEntityPredicate">The include entity predicate.</param>
1616
/// <returns>An AuditConfiguration.</returns>
1717
public AuditConfiguration Include(Func<object, bool> includeEntityPredicate)
@@ -20,7 +20,7 @@ public AuditConfiguration Include(Func<object, bool> includeEntityPredicate)
2020
return this;
2121
}
2222

23-
/// <summary>Includes from the audit all entities of 'T' type or entities which the type derive from 'T'.</summary>
23+
/// <summary>Includes (by entity type) from the audit all entities of 'T' type or entities which the type derive from 'T'.</summary>
2424
/// <typeparam name="T">Generic type to include.</typeparam>
2525
/// <returns>An AuditConfiguration.</returns>
2626
public AuditConfiguration Include<T>()

src/shared/Z.EF.Plus.Audit.Shared/AuditConfiguration/IsAuditedEntity.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public bool IsAuditedEntity(ObjectStateEntry entry)
2929
public bool IsAuditedEntity(EntityEntry entry)
3030
#endif
3131
{
32-
if (ExcludeIncludeEntityPredicates.Count == 0 || entry.Entity == null)
32+
if (entry.Entity == null
33+
|| (ExcludeIncludeEntityPredicates.Count == 0 && ExcludeIncludeByInstanceEntityPredicates.Count == 0))
3334
{
3435
return true;
3536
}
@@ -54,6 +55,15 @@ public bool IsAuditedEntity(EntityEntry entry)
5455
IsAuditedDictionary.TryAdd(key, value);
5556
}
5657

58+
foreach(var excludeIncludeByInstanceEntityFunc in ExcludeIncludeByInstanceEntityPredicates)
59+
{
60+
var maybeIncluded = excludeIncludeByInstanceEntityFunc(entry);
61+
if (maybeIncluded.HasValue)
62+
{
63+
value = maybeIncluded.Value;
64+
}
65+
}
66+
5767
return value;
5868
}
5969
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="SharedProjectFile_SccProperties">
44
<SharedProjectFile_ProjectGuid>{2ad53f92-e59b-4cba-b195-62918e6865fb}</SharedProjectFile_ProjectGuid>
5-
<SharedProjectFile_SccProjectName>SAK</SharedProjectFile_SccProjectName>
6-
<SharedProjectFile_SccAuxPath>SAK</SharedProjectFile_SccAuxPath>
7-
<SharedProjectFile_SccLocalPath>SAK</SharedProjectFile_SccLocalPath>
8-
<SharedProjectFile_SccProvider>SAK</SharedProjectFile_SccProvider>
5+
<SharedProjectFile_SccProjectName></SharedProjectFile_SccProjectName>
6+
<SharedProjectFile_SccAuxPath></SharedProjectFile_SccAuxPath>
7+
<SharedProjectFile_SccLocalPath></SharedProjectFile_SccLocalPath>
8+
<SharedProjectFile_SccProvider></SharedProjectFile_SccProvider>
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
@@ -19,8 +19,12 @@
1919
<Compile Include="$(MSBuildThisFileDirectory)Audit.cs" />
2020
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration.cs" />
2121
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\DisplayNameDataAnnotation.cs" />
22+
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\ExcludeByEntry.cs" />
2223
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\ExcludeDataAnnotation.cs" />
24+
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\ExcludeByInstance.cs" />
2325
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\ExcludeEntity.cs" />
26+
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\IncludeByEntry.cs" />
27+
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\IncludeByInstance.cs" />
2428
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\MetaProperty.cs" />
2529
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\ExcludeProperty.cs" />
2630
<Compile Include="$(MSBuildThisFileDirectory)AuditConfiguration\Format.cs" />

src/shared/Z.EF.Plus.Audit.Shared/Z.EF.Plus.Audit.Shared.shproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
<PropertyGroup Label="Globals">
44
<ProjectGuid>6bfa5473-a429-4f9e-aa40-1387716de22d</ProjectGuid>
55
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
6-
<SccProjectName>SAK</SccProjectName>
7-
<SccProvider>SAK</SccProvider>
8-
<SccAuxPath>SAK</SccAuxPath>
9-
<SccLocalPath>SAK</SccLocalPath>
6+
<SccProjectName>
7+
</SccProjectName>
8+
<SccProvider>
9+
</SccProvider>
10+
<SccAuxPath>
11+
</SccAuxPath>
12+
<SccLocalPath>
13+
</SccLocalPath>
1014
</PropertyGroup>
1115
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1216
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="SharedProjectFile_SccProperties">
44
<SharedProjectFile_ProjectGuid>{868b0e69-fb31-4d58-949c-fbf0f476d36c}</SharedProjectFile_ProjectGuid>
5-
<SharedProjectFile_SccProjectName>SAK</SharedProjectFile_SccProjectName>
6-
<SharedProjectFile_SccAuxPath>SAK</SharedProjectFile_SccAuxPath>
7-
<SharedProjectFile_SccLocalPath>SAK</SharedProjectFile_SccLocalPath>
8-
<SharedProjectFile_SccProvider>SAK</SharedProjectFile_SccProvider>
5+
<SharedProjectFile_SccProjectName></SharedProjectFile_SccProjectName>
6+
<SharedProjectFile_SccAuxPath></SharedProjectFile_SccAuxPath>
7+
<SharedProjectFile_SccLocalPath></SharedProjectFile_SccLocalPath>
8+
<SharedProjectFile_SccProvider></SharedProjectFile_SccProvider>
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

src/shared/Z.EF.Plus.BatchDelete.Shared/Z.EF.Plus.BatchDelete.Shared.shproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
<PropertyGroup Label="Globals">
44
<ProjectGuid>5b3fa372-a872-4ca1-b7c0-5352052ac75a</ProjectGuid>
55
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
6-
<SccProjectName>SAK</SccProjectName>
7-
<SccProvider>SAK</SccProvider>
8-
<SccAuxPath>SAK</SccAuxPath>
9-
<SccLocalPath>SAK</SccLocalPath>
6+
<SccProjectName>
7+
</SccProjectName>
8+
<SccProvider>
9+
</SccProvider>
10+
<SccAuxPath>
11+
</SccAuxPath>
12+
<SccLocalPath>
13+
</SccLocalPath>
1014
</PropertyGroup>
1115
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1216
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="SharedProjectFile_SccProperties">
44
<SharedProjectFile_ProjectGuid>{f53c2b9e-ca23-4465-b14a-6f72c6100b71}</SharedProjectFile_ProjectGuid>
5-
<SharedProjectFile_SccProjectName>SAK</SharedProjectFile_SccProjectName>
6-
<SharedProjectFile_SccAuxPath>SAK</SharedProjectFile_SccAuxPath>
7-
<SharedProjectFile_SccLocalPath>SAK</SharedProjectFile_SccLocalPath>
8-
<SharedProjectFile_SccProvider>SAK</SharedProjectFile_SccProvider>
5+
<SharedProjectFile_SccProjectName></SharedProjectFile_SccProjectName>
6+
<SharedProjectFile_SccAuxPath></SharedProjectFile_SccAuxPath>
7+
<SharedProjectFile_SccLocalPath></SharedProjectFile_SccLocalPath>
8+
<SharedProjectFile_SccProvider></SharedProjectFile_SccProvider>
99
</PropertyGroup>
1010
<PropertyGroup>
1111
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>

src/shared/Z.EF.Plus.BatchUpdate.Shared/Z.EF.Plus.BatchUpdate.Shared.shproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
<PropertyGroup Label="Globals">
44
<ProjectGuid>ce6171c3-84cc-4ae1-82d0-cdac97ef5ab2</ProjectGuid>
55
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
6-
<SccProjectName>SAK</SccProjectName>
7-
<SccProvider>SAK</SccProvider>
8-
<SccAuxPath>SAK</SccAuxPath>
9-
<SccLocalPath>SAK</SccLocalPath>
6+
<SccProjectName>
7+
</SccProjectName>
8+
<SccProvider>
9+
</SccProvider>
10+
<SccAuxPath>
11+
</SccAuxPath>
12+
<SccLocalPath>
13+
</SccLocalPath>
1014
</PropertyGroup>
1115
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1216
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />

src/shared/Z.EF.Plus.QueryCache.Shared/Extensions/IQueryable`/FromCache.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ public static IEnumerable<T> FromCache<T>(this IQueryable<T> query, MemoryCacheE
143143
{
144144
if (!QueryCacheManager.IsEnabled)
145145
{
146-
return query.AsNoTracking().ToList();
146+
return QueryCacheManager.ResolveAsNoTracking(query).ToList();
147147
}
148148

149149
var key = QueryCacheManager.GetCacheKey(query, tags);
150150

151151
object item;
152152
if (!QueryCacheManager.Cache.TryGetValue(key, out item))
153153
{
154-
item = query.AsNoTracking().ToList();
154+
item = QueryCacheManager.ResolveAsNoTracking(query).ToList();
155155
item = QueryCacheManager.Cache.Set(key, item, options);
156156
QueryCacheManager.AddCacheTag(key, tags);
157157
QueryCacheManager.AddCacheTag(key,typeof(T).Name + QueryCacheManager.CacheTypeSuffix);

src/shared/Z.EF.Plus.QueryCache.Shared/Extensions/IQueryable`/FromCacheAsync.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,15 @@ public static Task<IEnumerable<T>> FromCacheAsync<T>(this IQueryable<T> query, p
284284
{
285285
if (!QueryCacheManager.IsEnabled)
286286
{
287-
return await query.AsNoTracking().ToListAsync(cancellationToken).ConfigureAwait(false);
287+
return await QueryCacheManager.ResolveAsNoTracking(query).ToListAsync(cancellationToken).ConfigureAwait(false);
288288
}
289289

290290
var key = QueryCacheManager.GetCacheKey(query, tags, true);
291291

292292
object item;
293293
if (!QueryCacheManager.Cache.TryGetValue(key, out item))
294294
{
295-
item = await query.AsNoTracking().ToListAsync(cancellationToken).ConfigureAwait(false);
295+
item = await QueryCacheManager.ResolveAsNoTracking(query).ToListAsync(cancellationToken).ConfigureAwait(false);
296296
item = QueryCacheManager.Cache.Set(key, item, options);
297297
QueryCacheManager.AddCacheTag(key, tags);
298298
QueryCacheManager.AddCacheTag(key, typeof(T).Name + QueryCacheManager.CacheTypeSuffix);

0 commit comments

Comments
 (0)