示例#1
0
        public static void RunInTransaction(Action <DbConnection> func)
        {
            using (TransactionScope scope = GetRequiredTransactionScope())
            {
                DbConnection conn = ConnectionCache.GetConnection();

                func(conn);

                scope.Complete();
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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);
            }
        }