public ThrowingMonsterStateManager(
     IInternalEntityEntryFactory factory,
     IInternalEntityEntrySubscriber subscriber,
     IInternalEntityEntryNotifier notifier,
     IValueGenerationManager valueGeneration,
     IModel model,
     IDatabase database,
     IConcurrencyDetector concurrencyDetector,
     ICurrentDbContext currentContext)
     : base(factory, subscriber, notifier, valueGeneration, model, database, concurrencyDetector, currentContext)
 {
 }
示例#2
0
                public Enumerator(QueryingEnumerable <T> queryingEnumerable)
                {
                    _queryingEnumerable     = queryingEnumerable;
                    _cosmosQueryContext     = queryingEnumerable._cosmosQueryContext;
                    _shaper                 = queryingEnumerable._shaper;
                    _selectExpression       = queryingEnumerable._selectExpression;
                    _contextType            = queryingEnumerable._contextType;
                    _partitionKey           = queryingEnumerable._partitionKey;
                    _queryLogger            = queryingEnumerable._queryLogger;
                    _standAloneStateManager = queryingEnumerable._standAloneStateManager;

                    _concurrencyDetector = queryingEnumerable._threadSafetyChecksEnabled
                        ? _cosmosQueryContext.ConcurrencyDetector
                        : null;
                }
示例#3
0
                public Enumerator(ReadItemQueryingEnumerable <T> readItemEnumerable, CancellationToken cancellationToken = default)
                {
                    _cosmosQueryContext     = readItemEnumerable._cosmosQueryContext;
                    _readItemExpression     = readItemEnumerable._readItemExpression;
                    _shaper                 = readItemEnumerable._shaper;
                    _contextType            = readItemEnumerable._contextType;
                    _queryLogger            = readItemEnumerable._queryLogger;
                    _standAloneStateManager = readItemEnumerable._standAloneStateManager;
                    _readItemEnumerable     = readItemEnumerable;
                    _cancellationToken      = cancellationToken;

                    _concurrencyDetector = readItemEnumerable._concurrencyDetectionEnabled
                        ? _cosmosQueryContext.ConcurrencyDetector
                        : null;
                }
示例#4
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public RelationalQueryContext(
            [NotNull] Func <IQueryBuffer> queryBufferFactory,
            [NotNull] IRelationalConnection connection,
            [NotNull] LazyRef <IStateManager> stateManager,
            [NotNull] IConcurrencyDetector concurrencyDetector,
            [NotNull] IExecutionStrategyFactory executionStrategyFactory)
            : base(
                Check.NotNull(queryBufferFactory, nameof(queryBufferFactory)),
                Check.NotNull(stateManager, nameof(stateManager)),
                Check.NotNull(concurrencyDetector, nameof(concurrencyDetector)))
        {
            Check.NotNull(connection, nameof(connection));

            Connection = connection;
            ExecutionStrategyFactory = executionStrategyFactory;
        }
        public QueryContextDependencies(
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] IConcurrencyDetector concurrencyDetector,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Query> queryLogger)
        {
            Check.NotNull(currentContext, nameof(currentContext));
            Check.NotNull(concurrencyDetector, nameof(concurrencyDetector));
            Check.NotNull(commandLogger, nameof(commandLogger));
            Check.NotNull(queryLogger, nameof(queryLogger));

            CurrentContext      = currentContext;
            ConcurrencyDetector = concurrencyDetector;
            CommandLogger       = commandLogger;
            QueryLogger         = queryLogger;
        }
示例#6
0
                public AsyncEnumerator(QueryingEnumerable <T> queryingEnumerable, CancellationToken cancellationToken)
                {
                    _queryingEnumerable     = queryingEnumerable;
                    _cosmosQueryContext     = queryingEnumerable._cosmosQueryContext;
                    _shaper                 = queryingEnumerable._shaper;
                    _selectExpression       = queryingEnumerable._selectExpression;
                    _contextType            = queryingEnumerable._contextType;
                    _partitionKey           = queryingEnumerable._partitionKey;
                    _queryLogger            = queryingEnumerable._queryLogger;
                    _standAloneStateManager = queryingEnumerable._standAloneStateManager;
                    _cancellationToken      = cancellationToken;

                    _concurrencyDetector = queryingEnumerable._concurrencyDetectionEnabled
                        ? _cosmosQueryContext.ConcurrencyDetector
                        : null;
                }
示例#7
0
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="concurrencyDetector"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public StateManagerDependencies With([NotNull] IConcurrencyDetector concurrencyDetector)
 => new StateManagerDependencies(
     InternalEntityEntryFactory,
     InternalEntityEntrySubscriber,
     InternalEntityEntryNotifier,
     ValueGenerationManager,
     Model,
     Database,
     concurrencyDetector,
     CurrentContext,
     EntityFinderSource,
     SetSource,
     EntityMaterializerSource,
     LoggingOptions,
     UpdateLogger,
     ChangeTrackingLogger);
示例#8
0
        internal static T ExecuteReader <T>(this DatabaseFacade databaseFacade, string sql, object[] parameters, Func <DbDataReader, T> func)
        {
            T result = default(T);
            IRelationalDatabaseFacadeDependencies facadeDependencies = GetFacadeDependencies(databaseFacade);
            IConcurrencyDetector concurrencyDetector = ((IDatabaseFacadeDependencies)facadeDependencies).ConcurrencyDetector;
            IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger = ((IDatabaseFacadeDependencies)facadeDependencies).CommandLogger;

            using (concurrencyDetector.EnterCriticalSection())
            {
                var rawSqlCommand = databaseFacade.Build(sql, parameters);
                using (var reader = rawSqlCommand.RelationalCommand.ExecuteReader(new RelationalCommandParameterObject(facadeDependencies.RelationalConnection, rawSqlCommand.ParameterValues, null, ((IDatabaseFacadeDependenciesAccessor)databaseFacade).Context, commandLogger)))
                {
                    result = func.Invoke(reader.DbDataReader);
                }
            }
            return(result);
        }
示例#9
0
        private RelationalDataReader ExecuteSqlQuery(DatabaseFacade database, string sql, params object[] parameters)
        {
            IConcurrencyDetector concurrencyDetector = database.GetService <IConcurrencyDetector>();

            using (concurrencyDetector.EnterCriticalSection())
            {
                var rawSqlCommand = database
                                    .GetService <IRawSqlCommandBuilder>()
                                    .Build(sql, parameters);

                return(rawSqlCommand
                       .RelationalCommand
                       .ExecuteReader(
                           database.GetService <IRelationalConnection>(),
                           parameterValues: rawSqlCommand.ParameterValues));
            }
        }
示例#10
0
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used 
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public StateManager(
     [NotNull] IInternalEntityEntryFactory factory,
     [NotNull] IInternalEntityEntrySubscriber subscriber,
     [NotNull] IInternalEntityEntryNotifier notifier,
     [NotNull] IValueGenerationManager valueGeneration,
     [NotNull] IModel model,
     [NotNull] IDatabase database,
     [NotNull] IConcurrencyDetector concurrencyDetector,
     [NotNull] ICurrentDbContext currentContext)
 {
     _factory = factory;
     _subscriber = subscriber;
     Notify = notifier;
     ValueGeneration = valueGeneration;
     _model = model;
     _database = database;
     _concurrencyDetector = concurrencyDetector;
     Context = currentContext.Context;
 }
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 public RelationalDatabaseFacadeDependencies(
     [NotNull] IDbContextTransactionManager transactionManager,
     [NotNull] IDatabaseCreator databaseCreator,
     [NotNull] IExecutionStrategyFactory executionStrategyFactory,
     [NotNull] IEnumerable <IDatabaseProvider> databaseProviders,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> commandLogger,
     [NotNull] IConcurrencyDetector concurrencyDetector,
     [NotNull] IRelationalConnection relationalConnection,
     [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder)
 {
     TransactionManager       = transactionManager;
     DatabaseCreator          = databaseCreator;
     ExecutionStrategyFactory = executionStrategyFactory;
     DatabaseProviders        = databaseProviders;
     CommandLogger            = commandLogger;
     ConcurrencyDetector      = concurrencyDetector;
     RelationalConnection     = relationalConnection;
     RawSqlCommandBuilder     = rawSqlCommandBuilder;
 }
示例#12
0
 public StateManager(
     [NotNull] IInternalEntityEntryFactory factory,
     [NotNull] IInternalEntityEntrySubscriber subscriber,
     [NotNull] IInternalEntityEntryNotifier notifier,
     [NotNull] IValueGenerationManager valueGeneration,
     [NotNull] IModel model,
     [NotNull] IDatabase database,
     [NotNull] IConcurrencyDetector concurrencyDetector,
     [NotNull] DbContext context)
 {
     _factory             = factory;
     _subscriber          = subscriber;
     Notify               = notifier;
     ValueGeneration      = valueGeneration;
     _model               = model;
     _database            = database;
     _concurrencyDetector = concurrencyDetector;
     Context              = context;
 }
示例#13
0
        /// <summary>
        ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
        ///     directly from your code. This API may change or be removed in future releases.
        /// </summary>
        public StateManager([NotNull] StateManagerDependencies dependencies)
        {
            _internalEntityEntryFactory    = dependencies.InternalEntityEntryFactory;
            _internalEntityEntrySubscriber = dependencies.InternalEntityEntrySubscriber;
            InternalEntityEntryNotifier    = dependencies.InternalEntityEntryNotifier;
            ValueGenerationManager         = dependencies.ValueGenerationManager;
            _model                   = dependencies.Model;
            _database                = dependencies.Database;
            _concurrencyDetector     = dependencies.ConcurrencyDetector;
            Context                  = dependencies.CurrentContext.Context;
            EntityFinderFactory      = new EntityFinderFactory(dependencies.EntityFinderSource, this, dependencies.SetSource, dependencies.CurrentContext.Context);
            EntityMaterializerSource = dependencies.EntityMaterializerSource;

            if (dependencies.LoggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }

            _updateLogger = dependencies.UpdateLogger;
        }
示例#14
0
        public static async Task <RelationalDataReader> ExecuteSqlQueryAsync(this DatabaseFacade databaseFacade,
                                                                             string sql,
                                                                             CancellationToken cancellationToken = default,
                                                                             params object[] parameters)
        {
            IConcurrencyDetector concurrencyDetector = databaseFacade.GetService <IConcurrencyDetector>();

            using (concurrencyDetector.EnterCriticalSection()) {
                RawSqlCommand rawSqlCommand = databaseFacade
                                              .GetService <IRawSqlCommandBuilder>()
                                              .Build(sql, parameters);

                return(await rawSqlCommand
                       .RelationalCommand
                       .ExecuteReaderAsync(
                           databaseFacade.GetService <IRelationalConnection>(),
                           parameterValues : rawSqlCommand.ParameterValues,
                           cancellationToken : cancellationToken));
            }
        }
        private static async Task <RelationalDataReader> ExecuteSqlQueryAsync(
            this DbContext dbContext,
            string sql,
            IEnumerable <object> parameters,
            CancellationToken cancellationToken = default)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (string.IsNullOrWhiteSpace(sql))
            {
                throw new ArgumentNullException(nameof(sql));
            }

            IConcurrencyDetector concurrencyDetector = dbContext.GetService <IConcurrencyDetector>();

            using (concurrencyDetector.EnterCriticalSection())
            {
                RawSqlCommand rawSqlCommand = dbContext
                                              .GetService <IRawSqlCommandBuilder>()
                                              .Build(sql, parameters);

                RelationalCommandParameterObject paramObject = new RelationalCommandParameterObject(
                    dbContext.GetService <IRelationalConnection>(),
                    rawSqlCommand.ParameterValues,
                    null,
                    null,
                    null);

                RelationalDataReader relationalDataReader = await rawSqlCommand
                                                            .RelationalCommand
                                                            .ExecuteReaderAsync(paramObject, cancellationToken);

                return(relationalDataReader);
            }
        }
 public FileContextQueryContextFactory(IStateManager stateManager, ICurrentDbContext context, IConcurrencyDetector concurrencyDetector, IChangeDetector changeDetector)
     : base(context, concurrencyDetector)
 {
 }
示例#17
0
 public MyQueryContextFactory(IStateManager stateManager,
                              IConcurrencyDetector concurrencyDetector,
                              IChangeDetector changeDetector)
     : base(stateManager, concurrencyDetector, changeDetector)
 {
 }
 public ZStateManager(IInternalEntityEntryFactory factory, IInternalEntityEntrySubscriber subscriber, IInternalEntityEntryNotifier notifier, IValueGenerationManager valueGeneration, IModel model, IDatabase database, IConcurrencyDetector concurrencyDetector, ICurrentDbContext currentContext, ILoggingOptions loggingOptions, IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger)
     : base(factory, subscriber, notifier, valueGeneration, model, database, concurrencyDetector, currentContext, loggingOptions, updateLogger)
 {
 }
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="concurrencyDetector"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public QueryContextDependencies With([NotNull] IConcurrencyDetector concurrencyDetector)
 => new QueryContextDependencies(CurrentContext, concurrencyDetector, CommandLogger, QueryLogger);
 /// <summary>
 ///     Constructs a new <see cref="ConcurrencyDetectorCriticalSectionDisposer" />.
 /// </summary>
 /// <param name="concurrencyDetector">
 ///     The <see cref="IConcurrencyDetector" /> on which the critical section will be exited.
 /// </param>
 public ConcurrencyDetectorCriticalSectionDisposer(IConcurrencyDetector concurrencyDetector)
 => _concurrencyDetector = concurrencyDetector;
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="concurrencyDetector"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public QueryContextDependencies With([NotNull] IConcurrencyDetector concurrencyDetector)
 => new QueryContextDependencies(CurrentDbContext, concurrencyDetector);
示例#22
0
 public ZStateManager(IInternalEntityEntryFactory factory, IInternalEntityEntrySubscriber subscriber, IInternalEntityEntryNotifier notifier, IValueGenerationManager valueGeneration, IModel model, IDatabase database, IConcurrencyDetector concurrencyDetector, ICurrentDbContext currentContext)
     : base(factory, subscriber, notifier, valueGeneration, model, database, concurrencyDetector, currentContext)
 {
 }
示例#23
0
 // public StateManager stateManager;
 public SecurityQueryContext([NotNull] BaseSecurityDbContext dbContext, [NotNull] Func <IQueryBuffer> queryBufferFactory, [NotNull] IStateManager stateManager, [NotNull] IConcurrencyDetector concurrencyDetector)
     : base(queryBufferFactory, new LazyRef <IStateManager>(stateManager), concurrencyDetector)
 {
     this.dbContext = dbContext;
 }
 public MyQueryContextFactory(IStateManager stateManager, 
     IConcurrencyDetector concurrencyDetector, 
     IChangeDetector changeDetector) 
     : base(stateManager, concurrencyDetector, changeDetector)
 {
 }
 public SecurityQueryContextFactory([NotNull] DbContext dbContext, [NotNull] ICurrentDbContext currentContext, [NotNull] IStateManager stateManager, [NotNull] IConcurrencyDetector concurrencyDetector, [NotNull] IChangeDetector changeDetector) : base(currentContext, concurrencyDetector)
 {
     this.dbContext           = (BaseSecurityDbContext)dbContext;
     this.stateManager        = new LazyRef <IStateManager>(stateManager);
     this.concurrencyDetector = concurrencyDetector;
 }