24 lines
746 B
C#
24 lines
746 B
C#
using System;
|
|
|
|
namespace Hncore.Infrastructure.Data
|
|
{
|
|
public class TransactionsHelper
|
|
{
|
|
public static void NoLockInvokeDB(Action action)
|
|
{
|
|
var transactionOptions = new System.Transactions.TransactionOptions();
|
|
transactionOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
|
|
using (var transactionScope = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOptions))
|
|
{
|
|
try
|
|
{
|
|
action();
|
|
}
|
|
finally
|
|
{
|
|
transactionScope.Complete();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |