diff --git a/EnLock/EnExtention.cs b/EnLock/EnExtention.cs index 5462589..5b39816 100644 --- a/EnLock/EnExtention.cs +++ b/EnLock/EnExtention.cs @@ -56,6 +56,21 @@ public static async Task> ToListWithNoLockAsync(this IQueryable qu } return result; } + public static List ToListWithNoLock(this IQueryable query) + { + List result = default; + using (var scope = new TransactionScope(TransactionScopeOption.Required, + new TransactionOptions() + { + IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted + }, + TransactionScopeAsyncFlowOption.Enabled)) + { + result = query.ToList(); + scope.Complete(); + } + return result; + } public static async Task ToFirstOrDefaultWithNoLockAsync(this IQueryable query, CancellationToken cancellationToken = default) { T result = default;