Пример #1
0
        internal async Task InitializeAsync()
        {
            IndexCommand.ResetQueryCache();
            Indexes       = new List <IIndexProvider>();
            ScopedIndexes = new List <Type>();
            ValidateConfiguration();

            _sessionPool = new ObjectPool <Session>(MakeSession, Configuration.SessionPoolSize);
            Dialect      = SqlDialectFactory.For(Configuration.ConnectionFactory.DbConnectionType);
            TypeNames    = new TypeService();

            using (var connection = Configuration.ConnectionFactory.CreateConnection())
            {
                await connection.OpenAsync();

                using (var transaction = connection.BeginTransaction(Configuration.IsolationLevel))
                {
                    var builder = new SchemaBuilder(Configuration, transaction);
                    await Configuration.IdGenerator.InitializeAsync(this, builder);

                    transaction.Commit();
                }
            }

            // Pre-initialize the default collection
            await InitializeCollectionAsync("");
        }
Пример #2
0
        /// <summary>
        /// Initializes a new transaction if none has been yet
        /// </summary>
        public IDbTransaction Demand()
        {
            CheckDisposed();

            if (_transaction == null)
            {
                if (_connection == null)
                {
                    _connection = _store.Configuration.ConnectionFactory.CreateConnection();

                    // The dialect could already be initialized if the session is reused
                    if (_dialect == null)
                    {
                        _dialect = SqlDialectFactory.For(_connection);
                    }
                }

                if (_connection.State == ConnectionState.Closed)
                {
                    _connection.Open();
                }

                // In the case of shared connections (InMemory) this can throw as the transation
                // might already be set by a concurrent thread on the same shared connection.
                _transaction = _connection.BeginTransaction(_isolationLevel);
            }

            return(_transaction);
        }
Пример #3
0
        internal async Task InitializeAsync()
        {
            IndexCommand.ResetQueryCache();
            Indexes       = new List <IIndexProvider>();
            ScopedIndexes = new List <Type>();
            ValidateConfiguration();

            _sessionPool = new ObjectPool <Session>(MakeSession, Configuration.SessionPoolSize);
            Dialect      = SqlDialectFactory.For(Configuration.ConnectionFactory.DbConnectionType);
            TypeNames    = new TypeService();

            using (var connection = Configuration.ConnectionFactory.CreateConnection())
            {
                await connection.OpenAsync();

                using (var transaction = connection.BeginTransaction())
                {
                    var builder = new SchemaBuilder(Configuration, transaction);
                    await Configuration.IdGenerator.InitializeAsync(this, builder);

                    transaction.Commit();
                }
                //)FIXME : in Oracle it's forbidden to index an already indexed column and PK/UK is already indexed
                //.AlterTable(LinearBlockIdGenerator.TableName, table => table
                //    .CreateIndex("IX_Dimension", "dimension")
            }

            // Pee-initialize the default collection
            await InitializeCollectionAsync(Dialect.NullString);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new transaction if none has been yet
        /// </summary>
        public IDbTransaction Demand()
        {
            CheckDisposed();

            if (_transaction == null)
            {
                if (_connection == null)
                {
                    _connection = _store.Configuration.ConnectionFactory.CreateConnection();

                    // The dialect could already be initialized if the session is reused
                    if (_dialect == null)
                    {
                        _dialect = SqlDialectFactory.For(_connection);
                    }
                }

                if (_connection.State == ConnectionState.Closed)
                {
                    _connection.Open();
                }

                _transaction = _connection.BeginTransaction(_isolationLevel);
            }

            return(_transaction);
        }
Пример #5
0
        public Session(Func <ISession, IDocumentStorage> storage, Store store, IsolationLevel isolationLevel)
        {
            _storage        = storage(this);
            _store          = store;
            _isolationLevel = isolationLevel;

            _maps = new Dictionary <IndexDescriptor, IList <MapState> >();

            _connection = _store.Configuration.ConnectionFactory.CreateConnection();
            _dialect    = SqlDialectFactory.For(_connection);
        }
Пример #6
0
        public void AfterConfigurationAssigned()
        {
            IndexCommand.ResetQueryCache();
            Indexes       = new List <IIndexProvider>();
            ScopedIndexes = new List <Type>();
            ValidateConfiguration();
            IdGenerator = new LinearBlockIdGenerator(Configuration.ConnectionFactory, Configuration.LinearBlockSize, Configuration.TablePrefix);

            _sessionPool = new ObjectPool <Session>(MakeSession, Configuration.SessionPoolSize);
            Dialect      = SqlDialectFactory.For(Configuration.ConnectionFactory.DbConnectionType);
        }
Пример #7
0
        public static ICommandInterpreter For(IDbConnection connection)
        {
            string connectionName = connection.GetType().Name.ToLower();

            if (!CommandInterpreters.ContainsKey(connectionName))
            {
                throw new ArgumentException("Unknown connection name: " + connectionName);
            }

            var dialect = SqlDialectFactory.For(connection);

            return(CommandInterpreters[connectionName](dialect));
        }