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();
            }
        }
Esempio n. 2
0
        internal static ShapelessBufferedDataRecord Initialize(
            string providerManifestToken, DbProviderServices providerServices, DbDataReader reader)
        {
            var record = new ShapelessBufferedDataRecord();

            record.ReadMetadata(providerManifestToken, providerServices, reader);

            var fieldCount = record.FieldCount;
            var resultSet  = new List <object[]>();

            if (record._spatialDataReader != null)
            {
                while (reader.Read())
                {
                    var row = new object[fieldCount];
                    for (var i = 0; i < fieldCount; i++)
                    {
                        if (reader.IsDBNull(i))
                        {
                            row[i] = DBNull.Value;
                        }
                        else if (record._geographyColumns[i])
                        {
                            row[i] = record._spatialDataReader.GetGeography(i);
                        }
                        else if (record._geometryColumns[i])
                        {
                            row[i] = record._spatialDataReader.GetGeometry(i);
                        }
                        else
                        {
                            row[i] = reader.GetValue(i);
                        }
                    }
                    resultSet.Add(row);
                }
            }
            else
            {
                while (reader.Read())
                {
                    var row = new object[fieldCount];
                    reader.GetValues(row);
                    resultSet.Add(row);
                }
            }

            record._rowCount  = resultSet.Count;
            record._resultSet = resultSet;
            return(record);
        }
Esempio n. 3
0
        internal static async Task <ShapelessBufferedDataRecord> InitializeAsync(
            string providerManifestToken,
            DbProviderServices providerSerivces,
            DbDataReader reader,
            CancellationToken cancellationToken)
        {
            ShapelessBufferedDataRecord record = new ShapelessBufferedDataRecord();

            record.ReadMetadata(providerManifestToken, providerSerivces, reader);
            int             fieldCount = record.FieldCount;
            List <object[]> resultSet  = new List <object[]>();

            while (true)
            {
                if (await reader.ReadAsync(cancellationToken).WithCurrentCulture <bool>())
                {
                    object[] row = new object[fieldCount];
                    for (int i = 0; i < fieldCount; ++i)
                    {
                        if (await reader.IsDBNullAsync(i, cancellationToken).WithCurrentCulture <bool>())
                        {
                            row[i] = (object)DBNull.Value;
                        }
                        else if (record._spatialDataReader != null && record._geographyColumns[i])
                        {
                            row[i] = (object)await record._spatialDataReader.GetGeographyAsync(i, cancellationToken).WithCurrentCulture <DbGeography>();
                        }
                        else if (record._spatialDataReader != null && record._geometryColumns[i])
                        {
                            row[i] = (object)await record._spatialDataReader.GetGeometryAsync(i, cancellationToken).WithCurrentCulture <DbGeometry>();
                        }
                        else
                        {
                            row[i] = await reader.GetFieldValueAsync <object>(i, cancellationToken).WithCurrentCulture <object>();
                        }
                    }
                    resultSet.Add(row);
                }
                else
                {
                    break;
                }
            }
            record._rowCount  = resultSet.Count;
            record._resultSet = resultSet;
            return(record);
        }
        internal async Task InitializeAsync(
            string providerManifestToken, DbProviderServices providerSerivces, Type[] columnTypes, bool[] nullableColumns,
            CancellationToken cancellationToken)
        {
            if (_underlyingReader == null)
            {
                return;
            }

            cancellationToken.ThrowIfCancellationRequested();

            var reader = _underlyingReader;

            _underlyingReader = null;

            try
            {
                if (columnTypes != null && reader.GetType().Name != "SqlDataReader")
                {
                    _bufferedDataRecords.Add(await
                                             ShapedBufferedDataRecord.InitializeAsync(
                                                 providerManifestToken, providerSerivces, reader, columnTypes, nullableColumns, cancellationToken)
                                             .ConfigureAwait(continueOnCapturedContext: false));
                }
                else
                {
                    _bufferedDataRecords.Add(await
                                             ShapelessBufferedDataRecord.InitializeAsync(providerManifestToken, providerSerivces, reader, cancellationToken)
                                             .ConfigureAwait(continueOnCapturedContext: false));
                }

                while (await reader.NextResultAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
                {
                    _bufferedDataRecords.Add(await
                                             ShapelessBufferedDataRecord.InitializeAsync(providerManifestToken, providerSerivces, reader, cancellationToken)
                                             .ConfigureAwait(continueOnCapturedContext: false));
                }

                _recordsAffected  = reader.RecordsAffected;
                _currentResultSet = _bufferedDataRecords[_currentResultSetNumber];
            }
            finally
            {
                reader.Dispose();
            }
        }
        internal static async Task <ShapelessBufferedDataRecord> InitializeAsync(
            string providerManifestToken, DbProviderServices providerSerivces, DbDataReader reader, CancellationToken cancellationToken)
        {
            var record = new ShapelessBufferedDataRecord();

            record.ReadMetadata(providerManifestToken, providerSerivces, reader);

            var fieldCount = record.FieldCount;
            var resultSet  = new List <object[]>();

            while (await reader.ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
            {
                var row = new object[fieldCount];
                for (var i = 0; i < fieldCount; i++)
                {
                    if (await reader.IsDBNullAsync(i, cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
                    {
                        row[i] = DBNull.Value;
                    }
                    else if (record._spatialDataReader != null &&
                             record._geographyColumns[i])
                    {
                        row[i] = await record._spatialDataReader.GetGeographyAsync(i, cancellationToken)
                                 .ConfigureAwait(continueOnCapturedContext: false);
                    }
                    else if (record._spatialDataReader != null &&
                             record._geometryColumns[i])
                    {
                        row[i] = await record._spatialDataReader.GetGeometryAsync(i, cancellationToken)
                                 .ConfigureAwait(continueOnCapturedContext: false);
                    }
                    else
                    {
                        row[i] = await reader.GetFieldValueAsync <object>(i, cancellationToken)
                                 .ConfigureAwait(continueOnCapturedContext: false);
                    }
                }
                resultSet.Add(row);
            }

            record._rowCount  = resultSet.Count;
            record._resultSet = resultSet;
            return(record);
        }
        internal async Task InitializeAsync(
            string providerManifestToken,
            DbProviderServices providerSerivces,
            Type[] columnTypes,
            bool[] nullableColumns,
            CancellationToken cancellationToken)
        {
            if (this._underlyingReader == null)
            {
                return;
            }
            cancellationToken.ThrowIfCancellationRequested();
            DbDataReader reader = this._underlyingReader;

            this._underlyingReader = (DbDataReader)null;
            try
            {
                if (columnTypes != null && reader.GetType().Name != "SqlDataReader")
                {
                    this._bufferedDataRecords.Add(await ShapedBufferedDataRecord.InitializeAsync(providerManifestToken, providerSerivces, reader, columnTypes, nullableColumns, cancellationToken).WithCurrentCulture <BufferedDataRecord>());
                }
                else
                {
                    this._bufferedDataRecords.Add((BufferedDataRecord)await ShapelessBufferedDataRecord.InitializeAsync(providerManifestToken, providerSerivces, reader, cancellationToken).WithCurrentCulture <ShapelessBufferedDataRecord>());
                }
                while (true)
                {
                    if (await reader.NextResultAsync(cancellationToken).WithCurrentCulture <bool>())
                    {
                        this._bufferedDataRecords.Add((BufferedDataRecord)await ShapelessBufferedDataRecord.InitializeAsync(providerManifestToken, providerSerivces, reader, cancellationToken).WithCurrentCulture <ShapelessBufferedDataRecord>());
                    }
                    else
                    {
                        break;
                    }
                }
                this._recordsAffected  = reader.RecordsAffected;
                this._currentResultSet = this._bufferedDataRecords[this._currentResultSetNumber];
            }
            finally
            {
                reader.Dispose();
            }
        }
Esempio n. 7
0
        internal static ShapelessBufferedDataRecord Initialize(
            string providerManifestToken,
            DbProviderServices providerSerivces,
            DbDataReader reader)
        {
            ShapelessBufferedDataRecord bufferedDataRecord = new ShapelessBufferedDataRecord();

            bufferedDataRecord.ReadMetadata(providerManifestToken, providerSerivces, reader);
            int             fieldCount   = bufferedDataRecord.FieldCount;
            List <object[]> objArrayList = new List <object[]>();

            if (bufferedDataRecord._spatialDataReader != null)
            {
                while (reader.Read())
                {
                    object[] objArray = new object[fieldCount];
                    for (int ordinal = 0; ordinal < fieldCount; ++ordinal)
                    {
                        objArray[ordinal] = !reader.IsDBNull(ordinal) ? (!bufferedDataRecord._geographyColumns[ordinal] ? (!bufferedDataRecord._geometryColumns[ordinal] ? reader.GetValue(ordinal) : (object)bufferedDataRecord._spatialDataReader.GetGeometry(ordinal)) : (object)bufferedDataRecord._spatialDataReader.GetGeography(ordinal)) : (object)DBNull.Value;
                    }
                    objArrayList.Add(objArray);
                }
            }
            else
            {
                while (reader.Read())
                {
                    object[] values = new object[fieldCount];
                    reader.GetValues(values);
                    objArrayList.Add(values);
                }
            }
            bufferedDataRecord._rowCount  = objArrayList.Count;
            bufferedDataRecord._resultSet = objArrayList;
            return(bufferedDataRecord);
        }
        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();
            }
        }