private static ICommandBatchPreparer CreateCommandBatchPreparer(
            IModificationCommandBatchFactory modificationCommandBatchFactory = null,
            ICurrentDbContext currentDbContext = null,
            bool sensitiveLogging = false)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory
                ?? RelationalTestHelpers.Instance.CreateContextServices().GetRequiredService <IModificationCommandBatchFactory>();

            currentDbContext = currentDbContext
                               ?? RelationalTestHelpers.Instance.CreateContextServices().GetRequiredService <ICurrentDbContext>();

            var loggingOptions = new LoggingOptions();

            if (sensitiveLogging)
            {
                loggingOptions.Initialize(new DbContextOptionsBuilder <DbContext>().EnableSensitiveDataLogging().Options);
            }

            return(new CommandBatchPreparer(modificationCommandBatchFactory,
                                            new ParameterNameGeneratorFactory(new ParameterNameGeneratorDependencies()),
                                            new ModificationCommandComparer(),
                                            new KeyValueIndexFactorySource(),
                                            currentDbContext,
                                            loggingOptions));
        }
示例#2
0
        public ICommandBatchPreparer CreateCommandBatchPreparer(
            IModificationCommandBatchFactory modificationCommandBatchFactory = null,
            IStateManager stateManager = null,
            bool sensitiveLogging      = false)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory
                ?? RelationalTestHelpers.Instance.CreateContextServices().GetRequiredService <IModificationCommandBatchFactory>();

            stateManager = stateManager
                           ?? RelationalTestHelpers.Instance.CreateContextServices().GetRequiredService <IStateManager>();

            var loggingOptions = new LoggingOptions();

            if (sensitiveLogging)
            {
                loggingOptions.Initialize(new DbContextOptionsBuilder <DbContext>().EnableSensitiveDataLogging().Options);
            }

            return(new CommandBatchPreparer(
                       new CommandBatchPreparerDependencies(
                           modificationCommandBatchFactory,
                           new ParameterNameGeneratorFactory(new ParameterNameGeneratorDependencies()),
                           new ModificationCommandComparer(),
                           new KeyValueIndexFactorySource(),
                           () => stateManager,
                           loggingOptions,
                           new FakeDiagnosticsLogger <DbLoggerCategory.Update>(),
                           new DbContextOptionsBuilder().Options)));
        }
示例#3
0
 /// <summary>
 ///     Clones this dependency parameter object with one service replaced.
 /// </summary>
 /// <param name="modificationCommandBatchFactory"> A replacement for the current dependency of this type. </param>
 /// <returns> A new parameter object with the given service replaced. </returns>
 public CommandBatchPreparerDependencies With([NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory)
 => new CommandBatchPreparerDependencies(
     modificationCommandBatchFactory,
     ParameterNameGeneratorFactory,
     ModificationCommandComparer,
     KeyValueIndexFactorySource,
     StateManager,
     LoggingOptions);
示例#4
0
 public MySQLCommandBatchPreparer(
     IModificationCommandBatchFactory modificationCommandBatchFactory,
     IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     IComparer <ModificationCommand> modificationCommandComparer,
     IRelationalAnnotationProvider annotations,
     MySQLValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(modificationCommandBatchFactory, parameterNameGeneratorFactory, modificationCommandComparer, annotations, valueBufferFactoryFactory)
 {
 }
 public CommandBatchPreparer(
     [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
     [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
     [NotNull] IRelationalAnnotationProvider annotations)
 {
     _modificationCommandBatchFactory = modificationCommandBatchFactory;
     _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
     _modificationCommandComparer     = modificationCommandComparer;
     _annotationProvider = annotations;
 }
示例#6
0
        private static ICommandBatchPreparer CreateCommandBatchPreparer(IModificationCommandBatchFactory modificationCommandBatchFactory = null)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory ?? new TestModificationCommandBatchFactory(
                    Mock.Of <ISqlGenerator>());

            return(new TestCommandBatchPreparer(modificationCommandBatchFactory,
                                                new ParameterNameGeneratorFactory(),
                                                new ModificationCommandComparer(),
                                                Mock.Of <IRelationalValueBufferFactoryFactory>(),
                                                new TestMetadataExtensionProvider()));
        }
 public CommandBatchPreparer(
     [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
     [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
     [NotNull] IRelationalAnnotationProvider annotations,
     [NotNull] IKeyValueIndexFactorySource keyValueIndexFactoryFactory)
 {
     _modificationCommandBatchFactory = modificationCommandBatchFactory;
     _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
     _modificationCommandComparer     = modificationCommandComparer;
     _annotationProvider          = annotations;
     _keyValueIndexFactoryFactory = keyValueIndexFactoryFactory;
 }
 /// <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 CommandBatchPreparer(
     [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
     [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     [NotNull] IComparer<ModificationCommand> modificationCommandComparer,
     [NotNull] IRelationalAnnotationProvider annotations,
     [NotNull] IKeyValueIndexFactorySource keyValueIndexFactoryFactory)
 {
     _modificationCommandBatchFactory = modificationCommandBatchFactory;
     _parameterNameGeneratorFactory = parameterNameGeneratorFactory;
     _modificationCommandComparer = modificationCommandComparer;
     _annotationProvider = annotations;
     _keyValueIndexFactoryFactory = keyValueIndexFactoryFactory;
 }
示例#9
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 CommandBatchPreparer([NotNull] CommandBatchPreparerDependencies dependencies)
        {
            _modificationCommandBatchFactory = dependencies.ModificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = dependencies.ParameterNameGeneratorFactory;
            _modificationCommandComparer     = dependencies.ModificationCommandComparer;
            _keyValueIndexFactorySource      = dependencies.KeyValueIndexFactorySource;
            Dependencies = dependencies;

            if (dependencies.LoggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }
        }
示例#10
0
 public TestCommandBatchPreparer(
     IModificationCommandBatchFactory modificationCommandBatchFactory,
     IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     IComparer <ModificationCommand> modificationCommandComparer,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     IRelationalMetadataExtensionProvider metadataExtensionProvider)
     : base(
         modificationCommandBatchFactory,
         parameterNameGeneratorFactory,
         modificationCommandComparer,
         valueBufferFactoryFactory,
         metadataExtensionProvider)
 {
 }
示例#11
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 CommandBatchPreparer([NotNull] CommandBatchPreparerDependencies dependencies)
        {
            _modificationCommandBatchFactory = dependencies.ModificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = dependencies.ParameterNameGeneratorFactory;
            _modificationCommandComparer     = dependencies.ModificationCommandComparer;
            _keyValueIndexFactorySource      = dependencies.KeyValueIndexFactorySource;
            _minBatchSize = dependencies.Options.Extensions.OfType <RelationalOptionsExtension>().FirstOrDefault()
                            ?.MinBatchSize ?? 4;
            Dependencies = dependencies;

            if (dependencies.LoggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }
        }
示例#12
0
        private static ICommandBatchPreparer CreateCommandBatchPreparer(IModificationCommandBatchFactory modificationCommandBatchFactory = null)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory ?? new TestModificationCommandBatchFactory(
                    Mock.Of <IRelationalCommandBuilderFactory>(),
                    Mock.Of <ISqlGenerationHelper>(),
                    Mock.Of <IUpdateSqlGenerator>(),
                    Mock.Of <IRelationalValueBufferFactoryFactory>());

            return(new CommandBatchPreparer(modificationCommandBatchFactory,
                                            new ParameterNameGeneratorFactory(),
                                            new ModificationCommandComparer(),
                                            new TestAnnotationProvider(),
                                            new KeyValueIndexFactorySource()));
        }
示例#13
0
 /// <summary>
 ///     <para>
 ///         Creates the service dependencies parameter object for a <see cref="CommandBatchPreparer" />.
 ///     </para>
 ///     <para>
 ///         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.
 ///     </para>
 ///     <para>
 ///         Do not call this constructor directly from either provider or application code as it may change
 ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
 ///         will be created and injected automatically by the dependency injection container. To create
 ///         an instance with some dependent services replaced, first resolve the object from the dependency
 ///         injection container, then replace selected services using the 'With...' methods. Do not call
 ///         the constructor at any point in this process.
 ///     </para>
 /// </summary>
 public CommandBatchPreparerDependencies(
     [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
     [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
     [NotNull] IKeyValueIndexFactorySource keyValueIndexFactorySource,
     [NotNull] Func <IStateManager> stateManager,
     [NotNull] ILoggingOptions loggingOptions)
 {
     ModificationCommandBatchFactory = modificationCommandBatchFactory;
     ParameterNameGeneratorFactory   = parameterNameGeneratorFactory;
     ModificationCommandComparer     = modificationCommandComparer;
     KeyValueIndexFactorySource      = keyValueIndexFactorySource;
     StateManager   = stateManager;
     LoggingOptions = loggingOptions;
 }
示例#14
0
 /// <summary>
 ///     <para>
 ///         Creates the service dependencies parameter object for a <see cref="CommandBatchPreparer" />.
 ///     </para>
 ///     <para>
 ///         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.
 ///     </para>
 ///     <para>
 ///         Do not call this constructor directly from either provider or application code as it may change
 ///         as new dependencies are added. Instead, use this type in your constructor so that an instance
 ///         will be created and injected automatically by the dependency injection container. To create
 ///         an instance with some dependent services replaced, first resolve the object from the dependency
 ///         injection container, then replace selected services using the 'With...' methods. Do not call
 ///         the constructor at any point in this process.
 ///     </para>
 /// </summary>
 public CommandBatchPreparerDependencies(
     [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
     [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
     [NotNull] IKeyValueIndexFactorySource keyValueIndexFactorySource,
     [NotNull] ILoggingOptions loggingOptions,
     [NotNull] IDiagnosticsLogger <DbLoggerCategory.Update> updateLogger,
     [NotNull] IDbContextOptions options)
 {
     ModificationCommandBatchFactory = modificationCommandBatchFactory;
     ParameterNameGeneratorFactory   = parameterNameGeneratorFactory;
     ModificationCommandComparer     = modificationCommandComparer;
     KeyValueIndexFactorySource      = keyValueIndexFactorySource;
     LoggingOptions = loggingOptions;
     UpdateLogger   = updateLogger;
     Options        = options;
 }
        public CommandBatchPreparer(
            [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
            [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
            [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IRelationalMetadataExtensionProvider metadataExtensions)
        {
            Check.NotNull(modificationCommandBatchFactory, nameof(modificationCommandBatchFactory));
            Check.NotNull(parameterNameGeneratorFactory, nameof(parameterNameGeneratorFactory));
            Check.NotNull(modificationCommandComparer, nameof(modificationCommandComparer));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(metadataExtensions, nameof(metadataExtensions));

            _modificationCommandBatchFactory = modificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
            _modificationCommandComparer     = modificationCommandComparer;
            _valueBufferFactoryFactory       = valueBufferFactoryFactory;
            _metadataExtensionProvider       = metadataExtensions;
        }
示例#16
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 CommandBatchPreparer(
            [NotNull] IModificationCommandBatchFactory modificationCommandBatchFactory,
            [NotNull] IParameterNameGeneratorFactory parameterNameGeneratorFactory,
            [NotNull] IComparer <ModificationCommand> modificationCommandComparer,
            [NotNull] IKeyValueIndexFactorySource keyValueIndexFactorySource,
            [NotNull] ICurrentDbContext currentContext,
            [NotNull] ILoggingOptions loggingOptions)
        {
            _modificationCommandBatchFactory = modificationCommandBatchFactory;
            _parameterNameGeneratorFactory   = parameterNameGeneratorFactory;
            _modificationCommandComparer     = modificationCommandComparer;
            _keyValueIndexFactorySource      = keyValueIndexFactorySource;
            _currentContext = currentContext;

            if (loggingOptions.IsSensitiveDataLoggingEnabled)
            {
                _sensitiveLoggingEnabled = true;
            }
        }
 public TestCommandBatchPreparer(
     IModificationCommandBatchFactory modificationCommandBatchFactory,
     IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     IComparer<ModificationCommand> modificationCommandComparer,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     IRelationalMetadataExtensionProvider metadataExtensionProvider)
     : base(
           modificationCommandBatchFactory,
           parameterNameGeneratorFactory,
           modificationCommandComparer,
           valueBufferFactoryFactory,
           metadataExtensionProvider)
 {
 }
        private static ICommandBatchPreparer CreateCommandBatchPreparer(IModificationCommandBatchFactory modificationCommandBatchFactory = null)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory ?? new TestModificationCommandBatchFactory(
                    Mock.Of<IUpdateSqlGenerator>());

            return new TestCommandBatchPreparer(modificationCommandBatchFactory,
                new ParameterNameGeneratorFactory(),
                new ModificationCommandComparer(),
                Mock.Of<IRelationalValueBufferFactoryFactory>(),
                new TestMetadataExtensionProvider());
        }
        private static ICommandBatchPreparer CreateCommandBatchPreparer(IModificationCommandBatchFactory modificationCommandBatchFactory = null)
        {
            modificationCommandBatchFactory =
                modificationCommandBatchFactory ?? new TestModificationCommandBatchFactory(
                    Mock.Of<IRelationalCommandBuilderFactory>(),
                    Mock.Of<ISqlGenerationHelper>(),
                    Mock.Of<IUpdateSqlGenerator>(),
                    Mock.Of<IRelationalValueBufferFactoryFactory>());

            return new CommandBatchPreparer(modificationCommandBatchFactory,
                new ParameterNameGeneratorFactory(),
                new ModificationCommandComparer(),
                new TestAnnotationProvider(),
                new KeyValueIndexFactorySource());
        }