当前位置: 首页>>代码示例>>C#>>正文


C# DbDataReader.ReadAsync方法代码示例

本文整理汇总了C#中System.Data.Common.DbDataReader.ReadAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DbDataReader.ReadAsync方法的具体用法?C# DbDataReader.ReadAsync怎么用?C# DbDataReader.ReadAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.Common.DbDataReader的用法示例。


在下文中一共展示了DbDataReader.ReadAsync方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PostprocessAsync

        public async Task PostprocessAsync(DbDataReader reader, IList<Exception> exceptions, CancellationToken token)
        {
            await reader.ReadAsync(token).ConfigureAwait(false);

            var values = await reader.GetFieldValueAsync<int[]>(0, token).ConfigureAwait(false);

            applyDataFromSproc(values);
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:8,代码来源:EventStreamVersioningCallback.cs

示例2: FillDataTableAsync

    /// <summary>
    /// 使用指定范围内的行异步填充 DataTable 并返回。
    /// </summary>
    /// <param name="dataReader">用来读取数据的 DataReader</param>
    /// <param name="startRecord">要填充的起始记录位置</param>
    /// <param name="maxRecords">最多填充的记录条数</param>
    /// <returns>填充好的 DataTable</returns>
    public async Task<DataTable> FillDataTableAsync( DbDataReader dataReader, int startRecord, int maxRecords )
    {

      var dataTable = new DataTable();

      base.FillSchema( dataTable, SchemaType.Source, dataReader );

      var array = new object[dataReader.FieldCount];

      while ( await dataReader.ReadAsync() )
      {
        dataReader.GetValues( array );
        dataTable.LoadDataRow( array, true );
      }

      return dataTable;
    }
开发者ID:whztt07,项目名称:DbUtility,代码行数:24,代码来源:DataTableAdapter.cs

示例3: ConsumeResultSetWithoutPropagationAsync

        protected virtual async Task<int> ConsumeResultSetWithoutPropagationAsync(int commandIndex, DbDataReader reader, DbContext context, CancellationToken cancellationToken)
        {
            var expectedRowsAffected = 1;
            while (++commandIndex < ResultSetEnds.Count
                   && !ResultSetEnds[commandIndex - 1])
            {
                Debug.Assert(!ModificationCommands[commandIndex].RequiresResultPropagation);

                expectedRowsAffected++;
            }

            if (await reader.ReadAsync(cancellationToken))
            {
                var rowsAffected = reader.GetInt32(0);
                if (rowsAffected != expectedRowsAffected)
                {
                    ThrowAggregateUpdateConcurrencyException(commandIndex, expectedRowsAffected, rowsAffected);
                }
            }
            else
            {
                ThrowAggregateUpdateConcurrencyException(commandIndex, 1, 0);
            }

            return commandIndex;
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:26,代码来源:AffectedCountModificationCommandBatch.cs

示例4: ConsumeResultSetWithPropagationAsync

        protected virtual async Task<int> ConsumeResultSetWithPropagationAsync(int commandIndex, DbDataReader reader, DbContext context, CancellationToken cancellationToken)
        {
            var rowsAffected = 0;
            do
            {
                var tableModification = ModificationCommands[commandIndex];
                Debug.Assert(tableModification.RequiresResultPropagation);

                if (!await reader.ReadAsync(cancellationToken))
                {
                    var expectedRowsAffected = rowsAffected + 1;
                    while (++commandIndex < ResultSetEnds.Count
                           && !ResultSetEnds[commandIndex - 1])
                    {
                        expectedRowsAffected++;
                    }

                    ThrowAggregateUpdateConcurrencyException(commandIndex, expectedRowsAffected, rowsAffected);
                }

                tableModification.PropagateResults(tableModification.ValueBufferFactory.Create(reader));
                rowsAffected++;
            }
            while (++commandIndex < ResultSetEnds.Count
                   && !ResultSetEnds[commandIndex - 1]);

            return commandIndex;
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:28,代码来源:AffectedCountModificationCommandBatch.cs

示例5: getLong

        private async Task<long> getLong(DbDataReader reader)
        {
            await reader.NextResultAsync(_token).ConfigureAwait(false);
            bool isAny = await reader.ReadAsync(_token).ConfigureAwait(false);

            if (!isAny) return 0;

            if (await reader.IsDBNullAsync(0, _token).ConfigureAwait(false))
            {
                return 0;
            }

            return await reader.GetFieldValueAsync<long>(0, _token).ConfigureAwait(false);
        }
开发者ID:JasperFx,项目名称:marten,代码行数:14,代码来源:Fetcher.cs

示例6: ConsumeResultSetWithoutPropagationAsync

        private async Task<int> ConsumeResultSetWithoutPropagationAsync(int commandIndex, DbDataReader reader, DbContext context, CancellationToken cancellationToken)
        {
            var expectedRowsAffected = 1;
            while (++commandIndex < ResultSetEnds.Count
                   && !ResultSetEnds[commandIndex - 1])
            {
                Debug.Assert(!ModificationCommands[commandIndex].RequiresResultPropagation);

                expectedRowsAffected++;
            }

            if (await reader.ReadAsync(cancellationToken).WithCurrentCulture())
            {
                var rowsAffected = reader.GetInt32(0);
                if (rowsAffected != expectedRowsAffected)
                {
                    throw new DbUpdateConcurrencyException(
                        Strings.UpdateConcurrencyException(expectedRowsAffected, rowsAffected),
                        context,
                        AggregateEntries(commandIndex, expectedRowsAffected));
                }
            }
            else
            {
                throw new DbUpdateConcurrencyException(
                    Strings.UpdateConcurrencyException(1, 0),
                    context,
                    AggregateEntries(commandIndex, expectedRowsAffected));
            }

            return commandIndex;
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:32,代码来源:ReaderModificationCommandBatch.cs

示例7: ConsumeResultSetWithPropagationAsync

        private async Task<int> ConsumeResultSetWithPropagationAsync(int commandIndex, DbDataReader reader, DbContext context, CancellationToken cancellationToken)
        {
            var rowsAffected = 0;
            var valueReader = new RelationalTypedValueReader(reader);
            do
            {
                var tableModification = ModificationCommands[commandIndex];
                Debug.Assert(tableModification.RequiresResultPropagation);

                if (!await reader.ReadAsync(cancellationToken).WithCurrentCulture())
                {
                    var expectedRowsAffected = rowsAffected + 1;
                    while (++commandIndex < ResultSetEnds.Count
                           && !ResultSetEnds[commandIndex - 1])
                    {
                        expectedRowsAffected++;
                    }

                    throw new DbUpdateConcurrencyException(
                        Strings.UpdateConcurrencyException(expectedRowsAffected, rowsAffected),
                        context,
                        AggregateEntries(commandIndex, expectedRowsAffected));
                }

                tableModification.PropagateResults(valueReader);
                rowsAffected++;
            }
            while (++commandIndex < ResultSetEnds.Count
                   && !ResultSetEnds[commandIndex - 1]);

            return commandIndex;
        }
开发者ID:thegido,项目名称:EntityFramework,代码行数:32,代码来源:ReaderModificationCommandBatch.cs

示例8: ParseReader

        private async Task<IEnumerable<Scope>> ParseReader(DbDataReader reader)
        {
            var resultList = new List<Scope>();

            var hasMoreRows = reader.ReadAsync();

            while (await hasMoreRows)
            {
                int scopeOrdinal = reader.GetOrdinal("model");
                string model = reader.GetString(scopeOrdinal);

                hasMoreRows = reader.ReadAsync();

                var scope = _serializer.Deserialize<Scope>(model);

                resultList.Add(scope);
            }

            return resultList;
        }
开发者ID:soundsmitten,项目名称:IdentityServer3.Postgres,代码行数:20,代码来源:NpgsqlScopeStore.cs


注:本文中的System.Data.Common.DbDataReader.ReadAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。