public static class ExtenstionMethods
{
private static TransactionScope _TransactionScope { get { return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted }); } }
public static List<T> ToListNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.ToList(query); }
}
public static IEnumerable<T> AsEnumerableNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.AsEnumerable(query); }
}
public static T FirstOrDefaultNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.FirstOrDefault(query); }
}
public static T[] ToArrayNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.ToArray(query); }
}
public static int CountNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.Count(query); }
}
public static bool AnyNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.Any(query); }
}
}
{
private static TransactionScope _TransactionScope { get { return new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted }); } }
public static List<T> ToListNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.ToList(query); }
}
public static IEnumerable<T> AsEnumerableNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.AsEnumerable(query); }
}
public static T FirstOrDefaultNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.FirstOrDefault(query); }
}
public static T[] ToArrayNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.ToArray(query); }
}
public static int CountNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.Count(query); }
}
public static bool AnyNoLock<T>(this IEnumerable<T> query)
{
using (_TransactionScope) { return Enumerable.Any(query); }
}
}
Comments
Post a Comment