protected virtual IRelationalValueBufferFactory CreateValueBufferFactory([NotNull] IReadOnlyList <ColumnModification> columnModifications)
 => _valueBufferFactoryFactory
 .Create(
     Check.NotNull(columnModifications, nameof(columnModifications))
     .Where(c => c.IsRead)
     .Select(c => c.Property.ClrType)
     .ToArray(),
     indexMap: null);
        /// <summary>
        /// Uses the return types (from the read only expression) to
        /// create a value buffer factory (either typed or untyped)
        /// </summary>
        /// <param name="relationalValueBufferFactoryFactory"></param>
        /// <param name="dataReader"></param>
        /// <returns></returns>
        public virtual IRelationalValueBufferFactory CreateValueBufferFactory(
            IRelationalValueBufferFactoryFactory relationalValueBufferFactoryFactory,
            DbDataReader dataReader
            )
        {
            Check.NotNull(relationalValueBufferFactoryFactory, nameof(relationalValueBufferFactoryFactory));

            return(relationalValueBufferFactoryFactory
                   .Create(
                       ReadOnlyExpression.GetReturnTypes().ToArray(),
                       indexMap: null
                       ));
        }
        /// <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 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));
        }
        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));
        }
        /// <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 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 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);
        }