Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryHandlerFactory" /> class.
 /// </summary>
 /// <param name="databaseQueryHandlerFactory">The <see cref="IDbQueryHandlerFactory" /> factory.</param>
 public QueryHandlerFactory(IDbQueryHandlerFactory databaseQueryHandlerFactory = null)
 {
     if (databaseQueryHandlerFactory != null)
     {
         this.container.Add(typeof(IDbQueryHandlerFactory), databaseQueryHandlerFactory);
     }
 }
        /// <summary>
        /// Creates database context scope.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="isTransactional">Indicates whether the scope supports transactions.</param>
        /// <returns>
        /// The instance of <see cref="T:IDataContextScope" />.
        /// </returns>
        public IDbContextScope CreateDbContextScope(string connectionString, bool isTransactional = false)
        {
            IDbRepositoryFactory     repositoryFactory     = this.repositoryFactory?.GetFactory <IDbRepositoryFactory>();
            IDbQueryHandlerFactory   queryHandlerFactory   = this.queryHandlerFactory?.GetFactory <IDbQueryHandlerFactory>();
            IDbCommandHandlerFactory commandHandlerFactory = this.commandHandlerFactory?.GetFactory <IDbCommandHandlerFactory>();

            return(new DbContextScope(connectionString, isTransactional, repositoryFactory, queryHandlerFactory, commandHandlerFactory));
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbContextScope" /> class.
        /// </summary>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="isTransactional">Indicates whether the scope should support database transactions.</param>
        /// <param name="repositoryFactory">The <see cref="IDbRepositoryFactory" /> factory.</param>
        /// <param name="queryHandlerFactory">The <see cref="IDbQueryHandlerFactory" /> factory.</param>
        /// <param name="commandHandlerFactory">The <see cref="IDbCommandHandlerFactory" /> factory.</param>
        public DbContextScope(string connectionString, bool isTransactional, IDbRepositoryFactory repositoryFactory = null, IDbQueryHandlerFactory queryHandlerFactory = null, IDbCommandHandlerFactory commandHandlerFactory = null)
        {
            DbContextScope.repositoryFactory     = repositoryFactory;
            DbContextScope.queryHandlerFactory   = queryHandlerFactory;
            DbContextScope.commandHandlerFactory = commandHandlerFactory;

            this.context = new DbContext(connectionString, isTransactional);
        }