diff --git a/src/EfOrderBy/RequiredOrder.cs b/src/EfOrderBy/RequiredOrder.cs index 19cccb5..8b310bd 100644 --- a/src/EfOrderBy/RequiredOrder.cs +++ b/src/EfOrderBy/RequiredOrder.cs @@ -1,13 +1,13 @@ static class RequiredOrder { - static ConcurrentBag validated = []; + static ConcurrentDictionary validated = []; public static void Validate(DbContext context) { var contextType = context.GetType(); // Only check and validate once per DbContext type - if (validated.Contains(contextType)) + if (validated.ContainsKey(contextType)) { return; } @@ -24,7 +24,7 @@ public static void Validate(DbContext context) // Marked only after validation succeeds, so a failed validation keeps throwing // instead of silently passing on every subsequent query - validated.Add(contextType); + validated.TryAdd(contextType, true); } static void ValidateAllEntitiesHaveOrdering(IModel model)