Exemple #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));
        }
Exemple #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)
            });
        }
Exemple #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));
        }
Exemple #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));
        }
Exemple #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;
        }
Exemple #6
0
 public EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, TransactionOptions transactionOptions)
     : this(dependecyResolver, transactionOptions, useCurrentTransaction : false)
 {
 }
Exemple #7
0
 public EFUnitOfWork(ICqrsDependencyResolver dependecyResolver, bool enableTransactions)
     : this(dependecyResolver, enableTransactions, useCurrentTransaction : false)
 {
 }