public static void RunInTransaction(Action <DbConnection> func) { using (TransactionScope scope = GetRequiredTransactionScope()) { DbConnection conn = ConnectionCache.GetConnection(); func(conn); scope.Complete(); } }
private static object ExecuteCommmand(string spName, SqlCommandExecutor executor, params object[] parameterValues) { object res; using (TransactionScope scope = GetRequiredTransactionScope( )) { DbConnection conn = ConnectionCache.GetConnection( ); using (DbCommand cmd = CreateCommand(conn, spName, parameterValues)) { res = executor(cmd); } scope.Complete( ); } return(res); }
public static T RunInTransaction <T>(Func <DbConnection, T> func) { using (TransactionScope scope = GetRequiredTransactionScope()) { DbConnection conn = ConnectionCache.GetConnection(); var result = func(conn); scope.Complete(); return(result); } }