本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}