Skip to content

Commit

Permalink
ToListWithNoLock added
Browse files Browse the repository at this point in the history
  • Loading branch information
enisgurkann committed Jan 18, 2022
1 parent ce4c1ca commit 0d9b962
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions EnLock/EnExtention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ public static async Task<List<T>> ToListWithNoLockAsync<T>(this IQueryable<T> qu
}
return result;
}
public static List<T> ToListWithNoLock<T>(this IQueryable<T> query)
{
List<T> 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<T> ToFirstOrDefaultWithNoLockAsync<T>(this IQueryable<T> query, CancellationToken cancellationToken = default)
{
T result = default;
Expand Down

0 comments on commit 0d9b962

Please sign in to comment.