Skip to content

Commit

Permalink
Merge pull request #175 from Lempireqc/master
Browse files Browse the repository at this point in the history
save
  • Loading branch information
JonathanMagnan authored Oct 30, 2021
2 parents b3eda0e + 39acf64 commit a8869d7
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static class DynamicFilterExtensions
/// enabled/disabled. Once this is set, it cannot be undone because EF only gives us 1 shot at including those
/// conditions.
/// </summary>
private static HashSet<string> _PreventDisabledFilterConditions = new HashSet<string>();
private static ConcurrentDictionary<string, int> _PreventDisabledFilterConditions = new ConcurrentDictionary<string, int>();

#endregion

Expand Down Expand Up @@ -66,7 +66,7 @@ public static void ResetDynamicFilters(this DbModelBuilder modelBuilder)
{
_GlobalParameterValues = new ConcurrentDictionary<string, DynamicFilterParameters>();
_ScopedParameterValues = new ConcurrentDictionary<DbContext, ConcurrentDictionary<string, DynamicFilterParameters>>();
_PreventDisabledFilterConditions = new HashSet<string>();
_PreventDisabledFilterConditions = new ConcurrentDictionary<string, int>();
}

#endregion
Expand Down Expand Up @@ -514,7 +514,7 @@ public static void PreventAllDisabledFilterConditions(this DbModelBuilder modelB
// And if there are multiple DbContexts being used, setting it once would apply to all of them.
// So tracking this per filter so it can at least be managed by filter name.
foreach (var filterName in _GlobalParameterValues.Keys)
_PreventDisabledFilterConditions.Add(filterName);
_PreventDisabledFilterConditions.TryAdd(filterName, 1);
}

/// <summary>
Expand All @@ -530,7 +530,7 @@ public static void PreventDisabledFilterConditions(this DbModelBuilder modelBuil
if (!_GlobalParameterValues.ContainsKey(filterName))
throw new ApplicationException(string.Format("Filter {0} not defined", filterName));

_PreventDisabledFilterConditions.Add(filterName);
_PreventDisabledFilterConditions.TryAdd(filterName, 1);
}

/// <summary>
Expand All @@ -542,7 +542,7 @@ public static void PreventDisabledFilterConditions(this DbModelBuilder modelBuil
public static bool AreFilterDisabledConditionsAllowed(string filterName)
{
filterName = ScrubFilterName(filterName);
return !_PreventDisabledFilterConditions.Contains(filterName);
return !_PreventDisabledFilterConditions.ContainsKey(filterName);
}

#endregion
Expand Down

0 comments on commit a8869d7

Please sign in to comment.