コード例 #1
0
        /// <summary>
        /// On init.
        /// </summary>
        protected internal override void OnInit(Container container, IQueryable query, string key)
        {
            _connectionString = LinqToSql.GetConnectionString(query) ?? EntityFramework.GetConnectionString(query);
            if (_connectionString == null)
            {
                throw LinqCacheException.ContextIsNotSupported;
            }

            try
            {
                System.Data.SqlClient.SqlDependency.Start(_connectionString);
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message == BrokerNotEnabledMessage)
                {
                    throw LinqCacheException.BrokerIsNotEnabled(exception);
                }
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// On dispose.
        /// </summary>
        public void Dispose()
        {
            OnChangeReceived.Dispose();
            if (_connectionString == null)
            {
                return;
            }

            try
            {
                System.Data.SqlClient.SqlDependency.Stop(_connectionString);
            }
            catch (InvalidOperationException exception)
            {
                if (exception.Message == BrokerNotEnabledMessage)
                {
                    throw LinqCacheException.BrokerIsNotEnabled(exception);
                }

                throw;
            }
        }