Skip to content

Commit

Permalink
Add ShouldIgnoreDynamicFilterInterceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanMagnan committed Jan 26, 2022
1 parent 50b7aff commit aeed317
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public class DynamicFilterInterceptor : IDbCommandTreeInterceptor
{
public void TreeCreated(DbCommandTreeInterceptionContext interceptionContext)
{
// https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/153
if (DynamicFilterManager.ShouldIgnoreDynamicFilterInterceptor != null && DynamicFilterManager.ShouldIgnoreDynamicFilterInterceptor(interceptionContext)) return;

var queryCommand = interceptionContext.Result as DbQueryCommandTree;
if (queryCommand != null)
{
var context = interceptionContext.DbContexts.FirstOrDefault();
if (context != null)
{
// https://github.com/zzzprojects/EntityFramework.DynamicFilters/issues/153
if (context is HistoryContext) return;

DbExpressionVisitor<DbExpression> visitor;
#if (USE_CSPACE)
// Intercepting CSpace instead of SSpace gives us access to all of the navigation properties
Expand Down
15 changes: 15 additions & 0 deletions src/EntityFramework.DynamicFilters.Shared/DynamicFilterManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Data.Entity.Infrastructure.Interception;

namespace EntityFramework.DynamicFilters
{
/// <summary>Manager for dynamic filters.</summary>
public static class DynamicFilterManager
{
/// <summary>
/// Gets or sets if the DynamicFilterInterceptor should be ignored.
/// </summary>
/// <value>True if the DynamicFilterInterceptor should be ignored.</value>
public static Func<DbCommandTreeInterceptionContext, bool> ShouldIgnoreDynamicFilterInterceptor { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterDefinition.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterInterceptor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterParameters.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DynamicFilterQueryVisitorCSpace.cs" />
Expand Down

0 comments on commit aeed317

Please sign in to comment.