Ejemplo n.º 1
0
        public EFUnitOfWork(ICqrsDependencyResolver dependecyResolver)
            : base(dependecyResolver)
        {
            // Disable transaction
            this._transactionScope = null;

            // Create data context
            this._context    = new TDbContext();
            this._dataSource = new Lazy <IDataSource>(() => new EFDataSource(this._context));
            this._repository = new Lazy <IRepository>(() => (IRepository) new EFRepository(this._context));
        }
Ejemplo n.º 2
0
        protected UnitOfWorkBase(ICqrsDependencyResolver dependecyResolver)
        {
            Contract.Requires(dependecyResolver != null);

            this._dependencyResolver  = dependecyResolver;
            this._transactionCommands = new Queue <ICommandHandlerTransactionSupport>();

            this._paramsCache = new Lazy <CqrsParameterOverride[]>(() => new[] {
                new CqrsParameterOverride("repository", typeof(IRepository), this.Repository),
                new CqrsParameterOverride("dataSource", typeof(IDataSource), this.DataSource)
            });
        }
Ejemplo n.º 3
0
        private EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, TransactionOptions transactionOptions, bool useCurrentTransaction)
            : base(dependecyResolver)
        {
            // Enable transaction
            this._transactionOptions = transactionOptions;
            this._transactionScope   = new TransactionScope(
                useCurrentTransaction ? TransactionScopeOption.Required : TransactionScopeOption.RequiresNew,
                this._transactionOptions);

            // Create data context
            this._context    = new TDbContext();
            this._dataSource = new Lazy <IDataSource>(() => new EFDataSource(this._context));
            this._repository = new Lazy <IRepository>(() => (IRepository) new EFRepository(this._context));
        }
Ejemplo n.º 4
0
        private EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, bool enableTransactions, bool useCurrentTransaction)
            : base(dependecyResolver)
        {
            // Enable transaction if required
            if (enableTransactions)
            {
                this._transactionOptions = new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadUncommitted
                };
                this._transactionScope = new TransactionScope(
                    useCurrentTransaction ? TransactionScopeOption.Required : TransactionScopeOption.RequiresNew,
                    this._transactionOptions);
            }
            else
            {
                this._transactionScope = null;
            }

            // Create data context
            this._context    = new TDbContext();
            this._dataSource = new Lazy <IDataSource>(() => new EFDataSource(this._context));
            this._repository = new Lazy <IRepository>(() => (IRepository) new EFRepository(this._context));
        }
Ejemplo n.º 5
0
        /// <summary>Initializes a new instance of the <see cref="EFUnitOfWorkFactory{TDbContext}"/> class.</summary>
        /// <param name="dependencyResolver">The CQRS dependency resolver.</param>
        public EFUnitOfWorkFactory(ICqrsDependencyResolver dependencyResolver)
        {
            Contract.Requires(dependencyResolver != null);

            this._dependencyResolver = dependencyResolver;
        }
Ejemplo n.º 6
0
 public EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, TransactionOptions transactionOptions)
     : this(dependecyResolver, transactionOptions, useCurrentTransaction : false)
 {
 }
Ejemplo n.º 7
0
 public EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, bool enableTransactions)
     : this(dependecyResolver, enableTransactions, useCurrentTransaction : false)
 {
 }