示例#1
0
        /// <summary>
        /// return a <see cref="IUnitOfWork"/> based on the <see cref="System.Transactions.TransactionScope"/>.
        /// 当前Unit Work环境中,数据库的DTC不可用,UnitWork中的所有DAO方法采用同一个Connection.
        /// </summary>
        /// <param name="connString">A ConnectionString.</param>
        /// <param name="unitOfWorkDefinition">A UnitOfWorkDefinition.</param>
        /// <returns>返回事务单元管理者<see cref="IUnitOfWork"/>实例,该实例基于TransactionScope实现<see cref="IUnitOfWork"/>接口.</returns>
        public static IUnitOfWork GetTransactionScopeUnitOfWorkWithoutDTC(string connString,
                                                                          IUnitOfWorkDefinition unitOfWorkDefinition)
        {
            IDbProvider dbProvider = CreateDbProvider(connString);

            return(TransactionScopeUnitOfWorkFactory.Create()
                   .SetIsDtcAllowed(false)
                   .SetDbProvider(dbProvider)
                   .GetUnitOfWork(unitOfWorkDefinition));
        }
示例#2
0
 /// <summary>
 /// return a <see cref="IUnitOfWork"/> based on the <see cref="System.Transactions.TransactionScope"/>.
 /// 当前Unit Work环境中,数据库的DTC可用,则完全封装TransactionScope,不进行Conenction的压入线程;
 /// </summary>
 /// <returns>返回事务单元管理者<see cref="IUnitOfWork"/>实例,该实例基于TransactionScope实现<see cref="IUnitOfWork"/>接口.</returns>
 public static IUnitOfWork GetTransactionScopeUnitOfWorkWithDTCUsed()
 {
     return(TransactionScopeUnitOfWorkFactory.Create().SetIsDtcAllowed(true).GetUnitOfWork(null));
 }