@@ -35,7 +35,7 @@ public static class DynamicFilterExtensions
3535 /// enabled/disabled. Once this is set, it cannot be undone because EF only gives us 1 shot at including those
3636 /// conditions.
3737 /// </summary>
38- private static HashSet < string > _PreventDisabledFilterConditions = new HashSet < string > ( ) ;
38+ private static ConcurrentDictionary < string , int > _PreventDisabledFilterConditions = new ConcurrentDictionary < string , int > ( ) ;
3939
4040 #endregion
4141
@@ -66,7 +66,7 @@ public static void ResetDynamicFilters(this DbModelBuilder modelBuilder)
6666 {
6767 _GlobalParameterValues = new ConcurrentDictionary < string , DynamicFilterParameters > ( ) ;
6868 _ScopedParameterValues = new ConcurrentDictionary < DbContext , ConcurrentDictionary < string , DynamicFilterParameters > > ( ) ;
69- _PreventDisabledFilterConditions = new HashSet < string > ( ) ;
69+ _PreventDisabledFilterConditions = new ConcurrentDictionary < string , int > ( ) ;
7070 }
7171
7272 #endregion
@@ -514,7 +514,7 @@ public static void PreventAllDisabledFilterConditions(this DbModelBuilder modelB
514514 // And if there are multiple DbContexts being used, setting it once would apply to all of them.
515515 // So tracking this per filter so it can at least be managed by filter name.
516516 foreach ( var filterName in _GlobalParameterValues . Keys )
517- _PreventDisabledFilterConditions . Add ( filterName ) ;
517+ _PreventDisabledFilterConditions . TryAdd ( filterName , 1 ) ;
518518 }
519519
520520 /// <summary>
@@ -530,7 +530,7 @@ public static void PreventDisabledFilterConditions(this DbModelBuilder modelBuil
530530 if ( ! _GlobalParameterValues . ContainsKey ( filterName ) )
531531 throw new ApplicationException ( string . Format ( "Filter {0} not defined" , filterName ) ) ;
532532
533- _PreventDisabledFilterConditions . Add ( filterName ) ;
533+ _PreventDisabledFilterConditions . TryAdd ( filterName , 1 ) ;
534534 }
535535
536536 /// <summary>
@@ -542,7 +542,7 @@ public static void PreventDisabledFilterConditions(this DbModelBuilder modelBuil
542542 public static bool AreFilterDisabledConditionsAllowed ( string filterName )
543543 {
544544 filterName = ScrubFilterName ( filterName ) ;
545- return ! _PreventDisabledFilterConditions . Contains ( filterName ) ;
545+ return ! _PreventDisabledFilterConditions . ContainsKey ( filterName ) ;
546546 }
547547
548548 #endregion
0 commit comments