Skip to content

Commit aeed317

Browse files
Add ShouldIgnoreDynamicFilterInterceptor
1 parent 50b7aff commit aeed317

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/EntityFramework.DynamicFilters.Shared/DynamicFilterInterceptor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public class DynamicFilterInterceptor : IDbCommandTreeInterceptor
1111
{
1212
public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
1313
{
14+
// https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/153
15+
if (DynamicFilterManager.ShouldIgnoreDynamicFilterInterceptor != null && DynamicFilterManager.ShouldIgnoreDynamicFilterInterceptor(interceptionContext)) return;
16+
1417
var queryCommand = interceptionContext.Result as DbQueryCommandTree;
1518
if (queryCommand != null)
1619
{
1720
var context = interceptionContext.DbContexts.FirstOrDefault();
1821
if (context != null)
1922
{
20-
// https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/153
21-
if (context is HistoryContext) return;
22-
2323
DbExpressionVisitor<DbExpression> visitor;
2424
#if (USE_CSPACE)
2525
// Intercepting CSpace instead of SSpace gives us access to all of the navigation properties
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Data.Entity.Infrastructure.Interception;
3+
4+
namespace EntityFramework.DynamicFilters
5+
{
6+
/// <summary>Manager for dynamic filters.</summary>
7+
public static class DynamicFilterManager
8+
{
9+
/// <summary>
10+
/// Gets or sets if the DynamicFilterInterceptor should be ignored.
11+
/// </summary>
12+
/// <value>True if the DynamicFilterInterceptor should be ignored.</value>
13+
public static Func<DbCommandTreeInterceptionContext, bool> ShouldIgnoreDynamicFilterInterceptor { get; set; }
14+
}
15+
}

src/EntityFramework.DynamicFilters.Shared/EntityFramework.DynamicFilters.Shared.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterDefinition.cs" />
1616
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterExtensions.cs" />
1717
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterInterceptor.cs" />
18+
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterManager.cs" />
1819
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterOptions.cs" />
1920
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterParameters.cs" />
2021
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterQueryVisitorCSpace.cs" />

0 commit comments

Comments
 (0)