Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbCommandInfo"/> class.
        /// </summary>
        public DbCommandInfo(DbCommandTree tree, DbCache cache, IDbCachingPolicy policy, DbTransactionInterceptor txHandler)
        {
            Debug.Assert(tree != null);
            Debug.Assert(cache != null);
            Debug.Assert(txHandler != null);

            var qryTree = tree as DbQueryCommandTree;

            if (qryTree != null)
            {
                _isModification = false;

                _affectedEntitySets = GetAffectedEntitySets(qryTree.Query);
            }
            else
            {
                _isModification = true;

                var modify = tree as DbModificationCommandTree;

                if (modify != null)
                    _affectedEntitySets = GetAffectedEntitySets(modify.Target.Expression);
                else
                    // Functions (stored procedures) are not supported.
                    Debug.Assert(tree is DbFunctionCommandTree);
            }

            _cache = cache;
            _policy = policy;
            _txHandler = txHandler;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbCommandInfo"/> class.
        /// </summary>
        public DbCommandInfo(DbCommandTree tree, DbCache cache, IDbCachingPolicy policy, DbTransactionInterceptor txHandler)
        {
            Debug.Assert(tree != null);
            Debug.Assert(cache != null);
            Debug.Assert(txHandler != null);

            var qryTree = tree as DbQueryCommandTree;

            if (qryTree != null)
            {
                _isModification = false;

                _affectedEntitySets = GetAffectedEntitySets(qryTree.Query);
            }
            else
            {
                _isModification = true;

                var modify = tree as DbModificationCommandTree;

                if (modify != null)
                {
                    _affectedEntitySets = GetAffectedEntitySets(modify.Target.Expression);
                }
                else
                {
                    // Functions (stored procedures) are not supported.
                    Debug.Assert(tree is DbFunctionCommandTree);
                }
            }

            _cache     = cache;
            _policy    = policy;
            _txHandler = txHandler;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbProviderServicesProxy"/> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <param name="policy">The policy.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="txHandler">Transaction handler.</param>
        public DbProviderServicesProxy(DbProviderServices services, IDbCachingPolicy policy, DbCache cache, 
            DbTransactionInterceptor txHandler)
        {
            Debug.Assert(services != null);
            Debug.Assert(cache != null);
            Debug.Assert(txHandler != null);

            var proxy = services as DbProviderServicesProxy;
            _services = proxy != null ? proxy._services : services;

            _policy = policy ?? DefaultPolicy;
            _cache = cache;
            _txHandler = txHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DbProviderServicesProxy"/> class.
        /// </summary>
        /// <param name="services">The services.</param>
        /// <param name="policy">The policy.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="txHandler">Transaction handler.</param>
        public DbProviderServicesProxy(DbProviderServices services, IDbCachingPolicy policy, DbCache cache,
                                       DbTransactionInterceptor txHandler)
        {
            Debug.Assert(services != null);
            Debug.Assert(cache != null);
            Debug.Assert(txHandler != null);

            var proxy = services as DbProviderServicesProxy;

            _services = proxy != null ? proxy._services : services;

            _policy    = policy ?? DefaultPolicy;
            _cache     = cache;
            _txHandler = txHandler;
        }
Esempio n. 5
0
        /// <summary>
        /// Registers the provider services replacer.
        /// </summary>
        private static void RegisterProviderServicesReplacer(DbConfiguration config, 
            IDbCachingPolicy policy, DbCache efCache, DbTransactionInterceptor txHandler)
        {
            EventHandler<DbConfigurationLoadedEventArgs> onLoaded = null;

            onLoaded = (sender, args) =>
            {
                // Replace provider services for specific instance only and unsubscribe.
                if (ReferenceEquals(config, sender))
                {
                    // SetProviderServices is not suitable. We should replace whatever provider there is with our proxy.
                    args.ReplaceService<DbProviderServices>(
                        (services, a) => new DbProviderServicesProxy(services, policy, efCache, txHandler));

                    Loaded -= onLoaded;
                }
            };

            Loaded += onLoaded;
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes Ignite caching for specified <see cref="DbConfiguration"/>.
        /// This method should be used when it is not possible to use or inherit <see cref="IgniteDbConfiguration"/>.
        /// </summary>
        /// <param name="dbConfiguration"><see cref="DbConfiguration"/> instance to be initialized
        /// for Ignite caching.</param>
        /// <param name="ignite">The ignite instance to use.</param>
        /// <param name="metaCacheConfiguration">
        /// Configuration of the metadata cache which holds entity set information. Null for default configuration. 
        /// <para />
        /// This cache holds small amount of data, but should not lose entries. At least one backup recommended.
        /// </param>
        /// <param name="dataCacheConfiguration">
        /// Configuration of the data cache which holds query results. Null for default configuration.
        /// <para />
        /// This cache tolerates lost data and can have no backups.
        /// </param>
        /// <param name="policy">The caching policy. Null for default <see cref="DbCachingPolicy" />.</param>
        private static void InitializeIgniteCachingInternal(DbConfiguration dbConfiguration, IIgnite ignite, 
            CacheConfiguration metaCacheConfiguration, CacheConfiguration dataCacheConfiguration, 
            IDbCachingPolicy policy)
        {
            Debug.Assert(ignite != null);
            Debug.Assert(dbConfiguration != null);

            metaCacheConfiguration = metaCacheConfiguration ?? GetDefaultMetaCacheConfiguration();
            dataCacheConfiguration = dataCacheConfiguration ?? GetDefaultDataCacheConfiguration();

            var efCache = new DbCache(ignite, metaCacheConfiguration, dataCacheConfiguration);

            var txHandler = new DbTransactionInterceptor(efCache);

            AddInterceptorDelegate(dbConfiguration, txHandler);

            RegisterProviderServicesReplacer(dbConfiguration, policy, efCache, txHandler);
        }
Esempio n. 7
0
        public IgniteDbConfiguration(IIgnite ignite, CacheConfiguration metaCacheConfiguration,
            CacheConfiguration dataCacheConfiguration, IDbCachingPolicy policy)
        {
            IgniteArgumentCheck.NotNull(ignite, "ignite");

            metaCacheConfiguration = metaCacheConfiguration ?? GetDefaultMetaCacheConfiguration();
            dataCacheConfiguration = dataCacheConfiguration ?? GetDefaultDataCacheConfiguration();

            var efCache = new DbCache(ignite, metaCacheConfiguration, dataCacheConfiguration);

            var txHandler = new DbTransactionInterceptor(efCache);

            AddInterceptor(txHandler);

            // SetProviderServices is not suitable. We should replace whatever provider there is with our proxy.
            Loaded += (sender, args) => args.ReplaceService<DbProviderServices>(
                (services, a) => new DbProviderServicesProxy(services, policy, efCache, txHandler));
        }