internal void Initialize(
            string providerManifestToken,
            DbProviderServices providerServices,
            Type[] columnTypes,
            bool[] nullableColumns)
        {
            DbDataReader underlyingReader = this._underlyingReader;

            if (underlyingReader == null)
            {
                return;
            }
            this._underlyingReader = (DbDataReader)null;
            try
            {
                if (columnTypes != null && underlyingReader.GetType().Name != "SqlDataReader")
                {
                    this._bufferedDataRecords.Add(ShapedBufferedDataRecord.Initialize(providerManifestToken, providerServices, underlyingReader, columnTypes, nullableColumns));
                }
                else
                {
                    this._bufferedDataRecords.Add((BufferedDataRecord)ShapelessBufferedDataRecord.Initialize(providerManifestToken, providerServices, underlyingReader));
                }
                while (underlyingReader.NextResult())
                {
                    this._bufferedDataRecords.Add((BufferedDataRecord)ShapelessBufferedDataRecord.Initialize(providerManifestToken, providerServices, underlyingReader));
                }
                this._recordsAffected  = underlyingReader.RecordsAffected;
                this._currentResultSet = this._bufferedDataRecords[this._currentResultSetNumber];
            }
            finally
            {
                underlyingReader.Dispose();
            }
        }
Exemplo n.º 2
0
        internal static BufferedDataRecord Initialize(
            string providerManifestToken, DbProviderServices providerServices, DbDataReader reader, Type[] columnTypes,
            bool[] nullableColumns)
        {
            var record = new ShapedBufferedDataRecord();

            record.ReadMetadata(providerManifestToken, providerServices, reader);

            DbSpatialDataReader spatialDataReader = null;

            if (columnTypes.Any(t => t == typeof(DbGeography) || t == typeof(DbGeometry)))
            {
                spatialDataReader = providerServices.GetSpatialDataReader(reader, providerManifestToken);
            }

            return(record.Initialize(reader, spatialDataReader, columnTypes, nullableColumns));
        }
        internal void Initialize(
            string providerManifestToken, DbProviderServices providerServices, Type[] columnTypes, bool[] nullableColumns)
        {
            var reader = _underlyingReader;

            if (reader == null)
            {
                return;
            }
            _underlyingReader = null;

            try
            {
                if (columnTypes != null && reader.GetType().Name != "SqlDataReader")
                {
                    _bufferedDataRecords.Add(
                        ShapedBufferedDataRecord.Initialize(providerManifestToken, providerServices, reader, columnTypes, nullableColumns));
                }
                else
                {
                    _bufferedDataRecords.Add(ShapelessBufferedDataRecord.Initialize(providerManifestToken, providerServices, reader));
                }

                while (reader.NextResult())
                {
                    _bufferedDataRecords.Add(ShapelessBufferedDataRecord.Initialize(providerManifestToken, providerServices, reader));
                }

                _recordsAffected  = reader.RecordsAffected;
                _currentResultSet = _bufferedDataRecords[_currentResultSetNumber];
            }
            finally
            {
                reader.Dispose();
            }
        }