/// <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 ShaperCommandContext(
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     [NotNull] Func<IQuerySqlGenerator> querySqlGeneratorFactory)
 {
     _valueBufferFactoryFactory = valueBufferFactoryFactory;
     QuerySqlGeneratorFactory = querySqlGeneratorFactory;
 }
 public CommandBuilder(
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     [NotNull] Func<ISqlQueryGenerator> sqlGeneratorFunc)
 {
     _valueBufferFactoryFactory = valueBufferFactoryFactory;
     _sqlGeneratorFunc = sqlGeneratorFunc;
 }
        protected AffectedCountModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] IUpdateSqlGenerator sqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
            : base(commandBuilderFactory, sqlGenerator)
        {
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
        public SqliteModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _commandBuilderFactory = commandBuilderFactory;
            _updateSqlGenerator = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
        /// <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 override IRelationalValueBufferFactory CreateValueBufferFactory(
            IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
        {
            Check.NotNull(relationalValueBufferFactoryFactory, nameof(relationalValueBufferFactoryFactory));
            Check.NotNull(dataReader, nameof(dataReader));

            var readerColumns
                = Enumerable
                  .Range(0, dataReader.FieldCount)
                  .Select(
                      i => new
            {
                Name    = dataReader.GetName(i),
                Ordinal = i
            })
                  .ToList();

            var types = new TypeMaterializationInfo[SelectExpression.Projection.Count];

            for (var i = 0; i < SelectExpression.Projection.Count; i++)
            {
                if (SelectExpression.Projection[i] is ColumnExpression columnExpression)
                {
                    var columnName = columnExpression.Name;

                    if (columnName != null)
                    {
                        var readerColumn
                            = readerColumns.SingleOrDefault(
                                  c =>
                                  string.Equals(columnName, c.Name, StringComparison.OrdinalIgnoreCase));

                        if (readerColumn == null)
                        {
                            throw new InvalidOperationException(RelationalStrings.FromSqlMissingColumn(columnName));
                        }

                        types[i] = new TypeMaterializationInfo(
                            columnExpression.Type,
                            columnExpression.Property,
                            Dependencies.TypeMappingSource,
                            fromLeftOuterJoin: false,
                            readerColumn.Ordinal);
                    }
                }
            }

            return(relationalValueBufferFactoryFactory.Create(types));
        }
Example #6
0
        public NpgsqlModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [CanBeNull] int?maxBatchSize)
            : base(commandBuilderFactory, sqlGenerationHelper, updateSqlGenerator, valueBufferFactoryFactory)
        {
            if (maxBatchSize.HasValue && maxBatchSize.Value <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
            }

            _maxBatchSize = maxBatchSize ?? DefaultBatchSize;
        }
Example #7
0
        public SqlServerModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlServerUpdateSqlGenerator sqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [CanBeNull] int?maxBatchSize)
            : base(commandBuilderFactory, sqlGenerator, valueBufferFactoryFactory)
        {
            if (maxBatchSize.HasValue &&
                maxBatchSize.Value <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
            }

            _maxBatchSize = Math.Min(maxBatchSize ?? Int32.MaxValue, MaxRowCount);
        }
        /// <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 override IRelationalValueBufferFactory CreateValueBufferFactory(
            IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
        {
            Check.NotNull(relationalValueBufferFactoryFactory, nameof(relationalValueBufferFactoryFactory));
            Check.NotNull(dataReader, nameof(dataReader));

            var readerColumns
                = Enumerable
                  .Range(0, dataReader.FieldCount)
                  .Select(
                      i => new
            {
                Name    = dataReader.GetName(i),
                Ordinal = i
            })
                  .ToList();

            var types    = new Type[SelectExpression.Projection.Count];
            var indexMap = new int[SelectExpression.Projection.Count];

            for (var i = 0; i < SelectExpression.Projection.Count; i++)
            {
                if (SelectExpression.Projection[i] is ColumnExpression columnExpression)
                {
                    var columnName = columnExpression.Name;

                    if (columnName != null)
                    {
                        var readerColumn
                            = readerColumns.SingleOrDefault(
                                  c =>
                                  string.Equals(columnName, c.Name, StringComparison.OrdinalIgnoreCase));

                        if (readerColumn == null)
                        {
                            throw new InvalidOperationException(RelationalStrings.FromSqlMissingColumn(columnName));
                        }

                        types[i] = columnExpression.Property?.FindRelationalMapping()?.Converter?.StoreType
                                   ?? columnExpression.Type;

                        indexMap[i] = readerColumn.Ordinal;
                    }
                }
            }

            return(relationalValueBufferFactoryFactory.Create(types, indexMap));
        }
        public virtual IRelationalValueBufferFactory CreateValueBufferFactory(
            IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
        {
            Check.NotNull(relationalValueBufferFactoryFactory, nameof(relationalValueBufferFactoryFactory));
            Check.NotNull(dataReader, nameof(dataReader));

            var readerColumns
                = Enumerable
                  .Range(0, dataReader.FieldCount)
                  .Select(i => new
            {
                Name    = dataReader.GetName(i),
                Ordinal = i
            })
                  .ToList();

            var types    = new Type[_selectExpression.Projection.Count];
            var indexMap = new int[_selectExpression.Projection.Count];

            for (var i = 0; i < _selectExpression.Projection.Count; i++)
            {
                var aliasExpression = _selectExpression.Projection[i] as AliasExpression;

                if (aliasExpression != null)
                {
                    var columnName
                        = aliasExpression.Alias
                          ?? aliasExpression.TryGetColumnExpression()?.Name;

                    if (columnName != null)
                    {
                        var readerColumn
                            = readerColumns.SingleOrDefault(c =>
                                                            string.Equals(columnName, c.Name, StringComparison.OrdinalIgnoreCase));

                        if (readerColumn == null)
                        {
                            throw new InvalidOperationException(RelationalStrings.FromSqlMissingColumn(columnName));
                        }

                        types[i]    = _selectExpression.Projection[i].Type;
                        indexMap[i] = readerColumn.Ordinal;
                    }
                }
            }

            return(relationalValueBufferFactoryFactory.Create(types, indexMap));
        }
        public virtual IRelationalValueBufferFactory CreateValueBufferFactory(
            IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
        {
            Check.NotNull(relationalValueBufferFactoryFactory, nameof(relationalValueBufferFactoryFactory));
            Check.NotNull(dataReader, nameof(dataReader));

            var readerColumns
                = Enumerable
                    .Range(0, dataReader.FieldCount)
                    .Select(i => new
                    {
                        Name = dataReader.GetName(i),
                        Ordinal = i
                    })
                    .ToList();

            var types = new Type[_selectExpression.Projection.Count];
            var indexMap = new int[_selectExpression.Projection.Count];

            for (var i = 0; i < _selectExpression.Projection.Count; i++)
            {
                var aliasExpression = _selectExpression.Projection[i] as AliasExpression;

                if (aliasExpression != null)
                {
                    var columnName
                        = aliasExpression.Alias
                          ?? aliasExpression.TryGetColumnExpression()?.Name;

                    if (columnName != null)
                    {
                        var readerColumn
                            = readerColumns.SingleOrDefault(c =>
                                string.Equals(columnName, c.Name, StringComparison.OrdinalIgnoreCase));

                        if (readerColumn == null)
                        {
                            throw new InvalidOperationException(Strings.FromSqlMissingColumn(columnName));
                        }

                        types[i] = _selectExpression.Projection[i].Type;
                        indexMap[i] = readerColumn.Ordinal;
                    }
                }
            }

            return relationalValueBufferFactoryFactory.Create(types, indexMap);
        }
Example #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 FirebirdSqlModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            // ReSharper disable once SuggestBaseTypeForParameter
            [NotNull] IFirebirdSqlUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [CanBeNull] int?maxBatchSize)
            : base(commandBuilderFactory, sqlGenerationHelper, updateSqlGenerator, valueBufferFactoryFactory)
        {
            if (maxBatchSize.HasValue && maxBatchSize.Value <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
            }

            _maxBatchSize = Math.Min(maxBatchSize ?? int.MaxValue, MaxRowCount);
        }
        public SqlServerModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlServerUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDbContextOptions options)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(options, nameof(options));

            _commandBuilderFactory     = commandBuilderFactory;
            _updateSqlGenerator        = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
            _options = options;
        }
Example #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 TaosModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _commandBuilderFactory     = commandBuilderFactory;
            _sqlGenerationHelper       = sqlGenerationHelper;
            _updateSqlGenerator        = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
        public SqlServerModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlServerUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDbContextOptions options)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(options, nameof(options));

            _commandBuilderFactory = commandBuilderFactory;
            _updateSqlGenerator = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
            _options = options;
        }
        protected ReaderModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _commandBuilderFactory = commandBuilderFactory;
            SqlGenerationHelper = sqlGenerationHelper;
            UpdateSqlGenerator = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
        public MyCatModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper SqlGenerationHelper,
            [NotNull] IMyCatUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [CanBeNull] int?maxBatchSize)
            : base(commandBuilderFactory, SqlGenerationHelper, updateSqlGenerator, valueBufferFactoryFactory)
        {
            if (maxBatchSize.HasValue &&
                (maxBatchSize.Value <= 0))
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
            }

            _maxBatchSize = Math.Min(maxBatchSize ?? int.MaxValue, MaxRowCount);
        }
        public FbModificationCommandBatch(IRelationalCommandBuilderFactory commandBuilderFactory, ISqlGenerationHelper sqlGenerationHelper, IFbUpdateSqlGenerator updateSqlGenerator, IRelationalValueBufferFactoryFactory valueBufferFactoryFactory, int?maxBatchSize)
            : base(commandBuilderFactory, sqlGenerationHelper, updateSqlGenerator, valueBufferFactoryFactory)
        {
            if (maxBatchSize.HasValue && maxBatchSize.Value <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
            }

            _maxBatchSize          = Math.Min(maxBatchSize ?? int.MaxValue, MaxRowCount);
            _commandBuilderFactory = commandBuilderFactory;
            _valueBufferFactory    = valueBufferFactoryFactory;
            _executeParameters     = new StringBuilder();
            _seperator             = string.Empty;
            _bulkInsertCommands    = new List <ModificationCommand>();
            _bulkUpdateCommands    = new List <ModificationCommand>();
            _bulkDeleteCommands    = new List <ModificationCommand>();
        }
        protected RelationalDatabase(
            [NotNull] IModel model,
            [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
            [NotNull] IEntityMaterializerSource entityMaterializerSource,
            [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
            [NotNull] IRelationalConnection connection,
            [NotNull] ICommandBatchPreparer batchPreparer,
            [NotNull] IBatchExecutor batchExecutor,
            [NotNull] IDbContextOptions options,
            [NotNull] ILoggerFactory loggerFactory,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IMethodCallTranslator compositeMethodCallTranslator,
            [NotNull] IMemberTranslator compositeMemberTranslator,
            [NotNull] IRelationalTypeMapper typeMapper,
            [NotNull] IRelationalMetadataExtensionProvider relationalExtensions)
            : base(model, loggerFactory)
        {
            Check.NotNull(entityKeyFactorySource, nameof(entityKeyFactorySource));
            Check.NotNull(entityMaterializerSource, nameof(entityMaterializerSource));
            Check.NotNull(clrPropertyGetterSource, nameof(clrPropertyGetterSource));
            Check.NotNull(connection, nameof(connection));
            Check.NotNull(batchPreparer, nameof(batchPreparer));
            Check.NotNull(batchExecutor, nameof(batchExecutor));
            Check.NotNull(options, nameof(options));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(compositeMethodCallTranslator, nameof(compositeMethodCallTranslator));
            Check.NotNull(compositeMemberTranslator, nameof(compositeMemberTranslator));
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(relationalExtensions, nameof(relationalExtensions));

            EntityKeyFactorySource   = entityKeyFactorySource;
            EntityMaterializerSource = entityMaterializerSource;
            ClrPropertyGetterSource  = clrPropertyGetterSource;

            _batchPreparer = batchPreparer;
            _batchExecutor = batchExecutor;
            _connection    = connection;
            _options       = options;
            _compositeMethodCallTranslator = compositeMethodCallTranslator;
            _compositeMemberTranslator     = compositeMemberTranslator;

            TypeMapper = typeMapper;
            ValueBufferFactoryFactory = valueBufferFactoryFactory;
            RelationalExtensions      = relationalExtensions;
        }
Example #19
0
        protected ReaderModificationCommandBatch(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerator sqlGenerator,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(sqlGenerator, nameof(sqlGenerator));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _commandBuilderFactory = commandBuilderFactory;

            SqlGenerator       = sqlGenerator;
            UpdateSqlGenerator = updateSqlGenerator;

            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
Example #20
0
        public MySQLModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerator,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDbContextOptions options)
        {
            ThrowIf.Argument.IsNull(commandBuilderFactory, "commandBuilderFactory");
            ThrowIf.Argument.IsNull(updateSqlGenerator, "updateSqlGenerator");
            ThrowIf.Argument.IsNull(valueBufferFactoryFactory, "valueBufferFactoryFactory");
            ThrowIf.Argument.IsNull(options, "options");

            _commandBuilderFactory     = commandBuilderFactory;
            _sqlGenerator              = sqlGenerator;
            _updateSqlGenerator        = (MySQLUpdateSqlGenerator)updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
            _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;
        }
        public SqlCeModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder,
            [NotNull] ISqlCeUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDbContextOptions options)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(options, nameof(options));
            Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder));

            _commandBuilderFactory     = commandBuilderFactory;
            _sqlGenerationHelper       = sqlGenerationHelper;
            _updateSqlGenerator        = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
        /// <summary>
        ///     <para>
        ///         Creates the service dependencies parameter object for a <see cref="IModificationCommandBatchFactory" />.
        ///     </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>
        /// <param name="valueBufferFactoryFactory"> The value buffer factory. </param>
        /// <param name="commandBuilderFactory"> The command builder factory. </param>
        /// <param name="sqlGenerationHelper"> The sql generator. </param>
        /// <param name="updateSqlGenerator"> The update generator. </param>
        /// <param name="logger"> A logger. </param>
        public ModificationCommandBatchFactoryDependencies(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IUpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDiagnosticsLogger <DbLoggerCategory.Database.Command> logger)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(logger, nameof(logger));

            CommandBuilderFactory     = commandBuilderFactory;
            SqlGenerationHelper       = sqlGenerationHelper;
            UpdateSqlGenerator        = updateSqlGenerator;
            ValueBufferFactoryFactory = valueBufferFactoryFactory;
            Logger = logger;
        }
Example #24
0
        public ModificationCommand(
            [NotNull] string name,
            [CanBeNull] string schemaName,
            [NotNull] ParameterNameGenerator parameterNameGenerator,
            [NotNull] Func <IProperty, IRelationalPropertyAnnotations> getPropertyExtensions,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotEmpty(name, nameof(name));
            Check.NotNull(parameterNameGenerator, nameof(parameterNameGenerator));
            Check.NotNull(getPropertyExtensions, nameof(getPropertyExtensions));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            TableName                  = name;
            SchemaName                 = schemaName;
            ParameterNameGenerator     = parameterNameGenerator;
            _getPropertyExtensions     = getPropertyExtensions;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;

            _valueBufferFactory = new LazyRef <IRelationalValueBufferFactory>(CreateValueBufferFactory);
        }
Example #25
0
        public static Func <DbDataReader, TResult> GetMaterializer <TResult>(
            this DbContext dbContext,
            SelectExpression databaseExpression,
            IReadOnlyDictionary <string, object> parameters = null)
        {
            IMaterializerFactory       materializerFactory = dbContext.GetService <IMaterializerFactory>();
            Func <ValueBuffer, object> materializer        = (Func <ValueBuffer, object>)materializerFactory
                                                             .CreateMaterializer(
                entityType: dbContext.Model.FindEntityType(typeof(TResult)),
                selectExpression: databaseExpression,
                projectionAdder: (property, expression) => expression.AddToProjection(
                    property, databaseExpression.QuerySource),
                typeIndexMap: out _)
                                                             .Compile();
            IQuerySqlGeneratorFactory            sqlGeneratorFactory = dbContext.GetService <IQuerySqlGeneratorFactory>();
            IQuerySqlGenerator                   sqlGenerator        = sqlGeneratorFactory.CreateDefault(databaseExpression);
            IRelationalValueBufferFactoryFactory valueBufferFactory  = dbContext.GetService <IRelationalValueBufferFactoryFactory>();

            return(dbReader => (TResult)materializer(sqlGenerator.CreateValueBufferFactory(valueBufferFactory, dbReader).Create(dbReader)));
        }
        public ModificationCommand(
            [NotNull] string name,
            [CanBeNull] string schema,
            [NotNull] ParameterNameGenerator parameterNameGenerator,
            [NotNull] Func<IProperty, IRelationalPropertyAnnotations> getPropertyExtensions,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotEmpty(name, nameof(name));
            Check.NotNull(parameterNameGenerator, nameof(parameterNameGenerator));
            Check.NotNull(getPropertyExtensions, nameof(getPropertyExtensions));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            TableName = name;
            Schema = schema;
            ParameterNameGenerator = parameterNameGenerator;
            _getPropertyExtensions = getPropertyExtensions;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;

            _valueBufferFactory = new LazyRef<IRelationalValueBufferFactory>(CreateValueBufferFactory);
        }
Example #27
0
 public AS400ModificationCommandBatch(
     [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
     [NotNull] ISqlGenerationHelper sqlGenerationHelper,
     [NotNull] IAS400UpdateSqlGenerator updateSqlGenerator,
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     [NotNull] IRelationalConnection connection, //TODO: GetRidOf?
     [CanBeNull] int?maxBatchSize
     ) : base(
         commandBuilderFactory,
         sqlGenerationHelper,
         updateSqlGenerator,
         valueBufferFactoryFactory
         )
 {
     if (maxBatchSize.HasValue && maxBatchSize.Value <= 0)
     {
         throw new ArgumentOutOfRangeException(nameof(maxBatchSize), RelationalStrings.InvalidMaxBatchSize);
     }
     _connection   = connection;
     _maxBatchSize = Math.Min(maxBatchSize ?? int.MaxValue, MaxRowCount);
 }
Example #28
0
        public AS400ModificationCommandBatchFactory(
            [NotNull] IRelationalCommandBuilderFactory commandBuilderFactory,
            [NotNull] ISqlGenerationHelper sqlGenerationHelper,
            [NotNull] IAS400UpdateSqlGenerator updateSqlGenerator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IDbContextOptions options,
            [NotNull] IRelationalConnection connection)
        {
            Check.NotNull(commandBuilderFactory, nameof(commandBuilderFactory));
            Check.NotNull(sqlGenerationHelper, nameof(sqlGenerationHelper));
            Check.NotNull(updateSqlGenerator, nameof(updateSqlGenerator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(options, nameof(options));
            Check.NotNull(connection, nameof(connection));

            _commandBuilderFactory     = commandBuilderFactory;
            _sqlGenerationHelper       = sqlGenerationHelper;
            _updateSqlGenerator        = updateSqlGenerator;
            _valueBufferFactoryFactory = valueBufferFactoryFactory;
            _options    = options;
            _connection = connection;
        }
Example #29
0
        protected RelationalQueryCompilationContext(
            [NotNull] IModel model,
            [NotNull] ILogger logger,
            [NotNull] ILinqOperatorProvider linqOperatorProvider,
            [NotNull] IResultOperatorHandler resultOperatorHandler,
            [NotNull] IEntityMaterializerSource entityMaterializerSource,
            [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
            [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
            [NotNull] IQueryMethodProvider queryMethodProvider,
            [NotNull] IMethodCallTranslator compositeMethodCallTranslator,
            [NotNull] IMemberTranslator compositeMemberTranslator,
            [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
            [NotNull] IRelationalTypeMapper typeMapper,
            [NotNull] IRelationalMetadataExtensionProvider relationalExtensions)
            : base(
                model,
                logger,
                linqOperatorProvider,
                resultOperatorHandler,
                entityMaterializerSource,
                entityKeyFactorySource,
                clrPropertyGetterSource)

        {
            Check.NotNull(queryMethodProvider, nameof(queryMethodProvider));
            Check.NotNull(compositeMethodCallTranslator, nameof(compositeMethodCallTranslator));
            Check.NotNull(compositeMemberTranslator, nameof(compositeMemberTranslator));
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));
            Check.NotNull(typeMapper, nameof(typeMapper));
            Check.NotNull(relationalExtensions, nameof(relationalExtensions));

            QueryMethodProvider           = queryMethodProvider;
            CompositeMethodCallTranslator = compositeMethodCallTranslator;
            CompositeMemberTranslator     = compositeMemberTranslator;
            ValueBufferFactoryFactory     = valueBufferFactoryFactory;
            TypeMapper           = typeMapper;
            RelationalExtensions = relationalExtensions;
        }
 public SqliteQueryCompilationContext(
     [NotNull] IModel model,
     [NotNull] ILogger logger,
     [NotNull] ILinqOperatorProvider linqOperatorProvider,
     [NotNull] IResultOperatorHandler resultOperatorHandler,
     [NotNull] IEntityMaterializerSource entityMaterializerSource,
     [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
     [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
     [NotNull] IQueryMethodProvider queryMethodProvider,
     [NotNull] IMethodCallTranslator methodCallTranslator,
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
         model,
         logger,
         linqOperatorProvider,
         resultOperatorHandler,
         entityMaterializerSource,
         entityKeyFactorySource,
         clrPropertyGetterSource,
         queryMethodProvider,
         methodCallTranslator,
         valueBufferFactoryFactory)
 {
 }
 public SqliteDataStore(
     [NotNull] IModel model,
     [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
     [NotNull] IEntityMaterializerSource entityMaterializerSource,
     [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
     [NotNull] IRelationalConnection connection,
     [NotNull] ICommandBatchPreparer batchPreparer,
     [NotNull] IBatchExecutor batchExecutor,
     [NotNull] IEntityOptions options,
     [NotNull] ILoggerFactory loggerFactory,
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
         model,
         entityKeyFactorySource,
         entityMaterializerSource,
         clrPropertyGetterSource,
         connection,
         batchPreparer,
         batchExecutor,
         options,
         loggerFactory,
         valueBufferFactoryFactory)
 {
 }
 public SqlServerDataStore(
     [NotNull] IModel model,
     [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
     [NotNull] IEntityMaterializerSource entityMaterializerSource,
     [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
     [NotNull] ISqlServerConnection connection,
     [NotNull] ICommandBatchPreparer batchPreparer,
     [NotNull] IBatchExecutor batchExecutor,
     [NotNull] IEntityOptions options,
     [NotNull] ILoggerFactory loggerFactory,
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
         Check.NotNull(model, nameof(model)),
         Check.NotNull(entityKeyFactorySource, nameof(entityKeyFactorySource)),
         Check.NotNull(entityMaterializerSource, nameof(entityMaterializerSource)),
         Check.NotNull(clrPropertyGetterSource, nameof(clrPropertyGetterSource)),
         Check.NotNull(connection, nameof(connection)),
         Check.NotNull(batchPreparer, nameof(batchPreparer)),
         Check.NotNull(batchExecutor, nameof(batchExecutor)),
         Check.NotNull(options, nameof(options)),
         Check.NotNull(loggerFactory, nameof(loggerFactory)),
         Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory)))
 {
 }
Example #33
0
 public FakeRelationalDataStore(
     IModel model,
     IEntityKeyFactorySource entityKeyFactorySource,
     IEntityMaterializerSource entityMaterializerSource,
     IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
     IRelationalConnection connection,
     ICommandBatchPreparer batchPreparer,
     IBatchExecutor batchExecutor,
     IEntityOptions options,
     ILoggerFactory loggerFactory,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
         model,
         entityKeyFactorySource,
         entityMaterializerSource,
         clrPropertyGetterSource,
         connection,
         batchPreparer,
         batchExecutor,
         options,
         loggerFactory,
         valueBufferFactoryFactory)
 {
 }
 public override IRelationalValueBufferFactory CreateValueBufferFactory(IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
 {
     Check.NotNull(relationalValueBufferFactoryFactory, "relationalValueBufferFactoryFactory");
     Type[] array = SelectExpression.GetProjectionTypes().ToArray();
     if (array.Contains(Type.GetType("System.Boolean")) || array.Contains(Type.GetType("System.Nullable`1[System.Boolean]")))
     {
         int    num    = 0;
         Type[] array2 = array;
         for (int i = 0; i < array2.Length; i++)
         {
             if (array2[i].FullName.Contains("System.Boolean"))
             {
                 if (_overrideColumnReturnTypes == null)
                 {
                     _overrideColumnReturnTypes = new Dictionary <int, TypeCode>();
                 }
                 _overrideColumnReturnTypes.Add(num, TypeCode.Boolean);
             }
             num++;
         }
         //TODO:IsPrivate  ((DB2DataReader)dataReader).m_overrideColumnReturnTypes = _overrideColumnReturnTypes;
     }
     return(relationalValueBufferFactoryFactory.Create(array, null));
 }
 public SqlServerQueryCompilationContext(
     [NotNull] IModel model,
     [NotNull] ILogger logger,
     [NotNull] ILinqOperatorProvider linqOperatorProvider,
     [NotNull] IResultOperatorHandler resultOperatorHandler,
     [NotNull] IEntityMaterializerSource entityMaterializerSource,
     [NotNull] IEntityKeyFactorySource entityKeyFactorySource,
     [NotNull] IClrAccessorSource <IClrPropertyGetter> clrPropertyGetterSource,
     [NotNull] IQueryMethodProvider queryMethodProvider,
     [NotNull] IMethodCallTranslator methodCallTranslator,
     [NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
         Check.NotNull(model, nameof(model)),
         Check.NotNull(logger, nameof(logger)),
         Check.NotNull(linqOperatorProvider, nameof(linqOperatorProvider)),
         Check.NotNull(resultOperatorHandler, nameof(resultOperatorHandler)),
         Check.NotNull(entityMaterializerSource, nameof(entityMaterializerSource)),
         Check.NotNull(entityKeyFactorySource, nameof(entityKeyFactorySource)),
         Check.NotNull(clrPropertyGetterSource, nameof(clrPropertyGetterSource)),
         Check.NotNull(queryMethodProvider, nameof(queryMethodProvider)),
         Check.NotNull(methodCallTranslator, nameof(methodCallTranslator)),
         Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory)))
 {
 }
 public FactoryAndReader(IRelationalValueBufferFactoryFactory factory, DbDataReader reader)
 {
     Factory = factory;
     Reader = reader;
 }
 public TestCommandBatchPreparer(
     IModificationCommandBatchFactory modificationCommandBatchFactory,
     IParameterNameGeneratorFactory parameterNameGeneratorFactory,
     IComparer<ModificationCommand> modificationCommandComparer,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     IRelationalMetadataExtensionProvider metadataExtensionProvider)
     : base(
           modificationCommandBatchFactory,
           parameterNameGeneratorFactory,
           modificationCommandComparer,
           valueBufferFactoryFactory,
           metadataExtensionProvider)
 {
 }
 public FakeQueryCompilationContext(
     IModel model,
     ILogger logger,
     ILinqOperatorProvider linqOperatorProvider,
     IResultOperatorHandler resultOperatorHandler,
     IEntityMaterializerSource entityMaterializerSource,
     IClrAccessorSource<IClrPropertyGetter> clrPropertyGetterSource,
     IEntityKeyFactorySource entityKeyFactorySource,
     IQueryMethodProvider queryMethodProvider,
     IMethodCallTranslator compositeMethodCallTranslator,
     IMemberTranslator compositeMemberTranslator,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     IRelationalTypeMapper typeMapper,
     IRelationalMetadataExtensionProvider relationalExtensions)
     : base(
         model,
         logger,
         linqOperatorProvider,
         resultOperatorHandler,
         entityMaterializerSource,
         entityKeyFactorySource,
         clrPropertyGetterSource,
         queryMethodProvider,
         compositeMethodCallTranslator,
         compositeMemberTranslator,
         valueBufferFactoryFactory,
         typeMapper,
         relationalExtensions)
 {
 }
 public FakeRelationalDataStore(
     IModel model,
     IEntityKeyFactorySource entityKeyFactorySource,
     IEntityMaterializerSource entityMaterializerSource,
     IClrAccessorSource<IClrPropertyGetter> clrPropertyGetterSource,
     IRelationalConnection connection,
     ICommandBatchPreparer batchPreparer,
     IBatchExecutor batchExecutor,
     IEntityOptions options,
     ILoggerFactory loggerFactory,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
     : base(
           model, 
           entityKeyFactorySource, 
           entityMaterializerSource,
           clrPropertyGetterSource,
           connection, 
           batchPreparer, 
           batchExecutor, 
           options, 
           loggerFactory,
           valueBufferFactoryFactory)
 {
 }
 public FakeRelationalDatabase(
     IModel model,
     IEntityKeyFactorySource entityKeyFactorySource,
     IEntityMaterializerSource entityMaterializerSource,
     IClrAccessorSource<IClrPropertyGetter> clrPropertyGetterSource,
     IRelationalConnection connection,
     ICommandBatchPreparer batchPreparer,
     IBatchExecutor batchExecutor,
     IDbContextOptions options,
     ILoggerFactory loggerFactory,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory,
     IMethodCallTranslator compositeMethodCallTranslator,
     IMemberTranslator compositeMemberTranslator,
     IRelationalTypeMapper typeMapper)
     : base(
           model, 
           entityKeyFactorySource, 
           entityMaterializerSource,
           clrPropertyGetterSource,
           connection, 
           batchPreparer, 
           batchExecutor, 
           options, 
           loggerFactory,
           valueBufferFactoryFactory,
           compositeMethodCallTranslator,
           compositeMemberTranslator,
           typeMapper)
 {
 }
        public CommandBuilderFactory([NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
 public IRelationalValueBufferFactory CreateValueBufferFactory(IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory, DbDataReader dataReader)
 {
     throw new NotImplementedException();
 }
Example #43
0
 public FactoryAndReader(IRelationalValueBufferFactoryFactory factory, DbDataReader reader)
 {
     Factory = factory;
     Reader  = reader;
 }
 public TestModificationCommandBatchFactory(
     IRelationalCommandBuilderFactory commandBuilderfactory,
     ISqlGenerationHelper sqlGenerationHelper,
     IUpdateSqlGenerator updateSqlGenerator,
     IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
 {
     _commandBuilderFactory = commandBuilderfactory;
     _sqlGenerationHelper = sqlGenerationHelper;
     _updateSqlGenerator = updateSqlGenerator;
     _valueBufferFactoryFactory = valueBufferFactoryFactory;
 }
        public ShaperCommandContextFactory([NotNull] IRelationalValueBufferFactoryFactory valueBufferFactoryFactory)
        {
            Check.NotNull(valueBufferFactoryFactory, nameof(valueBufferFactoryFactory));

            _valueBufferFactoryFactory = valueBufferFactoryFactory;
        }
 public FbModificationCommandBatchFactory(IRelationalCommandBuilderFactory commandBuilderFactory, ISqlGenerationHelper sqlGenerationHelper, IUpdateSqlGenerator updateSqlGenerator, IRelationalValueBufferFactoryFactory valueBufferFactoryFactory, IDbContextOptions options)
 {
     _commandBuilderFactory     = commandBuilderFactory;
     _sqlGenerationHelper       = sqlGenerationHelper;
     _updateSqlGenerator        = updateSqlGenerator;
     _valueBufferFactoryFactory = valueBufferFactoryFactory;
     _options = options;
 }