本文整理汇总了C#中System.Data.Common.DbDataReader.NextResultAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DbDataReader.NextResultAsync方法的具体用法?C# DbDataReader.NextResultAsync怎么用?C# DbDataReader.NextResultAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Common.DbDataReader
的用法示例。
在下文中一共展示了DbDataReader.NextResultAsync方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Handle
public async Task Handle(DbDataReader reader, CancellationToken token)
{
var hasNext = await reader.NextResultAsync(token).ConfigureAwait(false);
if (!hasNext)
{
throw new InvalidOperationException("There is no next result to read over.");
}
await _inner.Handle(reader, token).ConfigureAwait(false);
}
示例2: ConsumeReaderAsync
/// <summary>
/// Asynchronously consumes all rows and result sets from the reader. This allows client to retrieve
/// parameter values and intercept any store exceptions.
/// </summary>
internal static async Task ConsumeReaderAsync(DbDataReader reader, CancellationToken cancellationToken)
{
if (null != reader
&& !reader.IsClosed)
{
while (await reader.NextResultAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))
{
// Note that we only walk through the result sets. We don't need
// to walk through individual rows (though underlying provider
// implementation may do so)
}
}
}
示例3: ConsumeReaderAsync
// <summary>
// Asynchronously consumes all rows and result sets from the reader. This allows client to retrieve
// parameter values and intercept any store exceptions.
// </summary>
internal static async Task ConsumeReaderAsync(DbDataReader reader, CancellationToken cancellationToken)
{
if (null != reader
&& !reader.IsClosed)
{
cancellationToken.ThrowIfCancellationRequested();
while (await reader.NextResultAsync(cancellationToken).WithCurrentCulture())
{
cancellationToken.ThrowIfCancellationRequested();
// Note that we only walk through the result sets. We don't need
// to walk through individual rows (though underlying provider
// implementation may do so)
}
}
}
示例4: ConsumeAsync
protected override async Task ConsumeAsync(
DbDataReader reader,
DbContext context,
CancellationToken cancellationToken = default(CancellationToken))
{
Debug.Assert(ResultSetEnds.Count == ModificationCommands.Count);
var commandIndex = 0;
try
{
var actualResultSetCount = 0;
do
{
commandIndex = ModificationCommands[commandIndex].RequiresResultPropagation
? await ConsumeResultSetWithPropagationAsync(commandIndex, reader, context, cancellationToken)
: await ConsumeResultSetWithoutPropagationAsync(commandIndex, reader, context, cancellationToken);
actualResultSetCount++;
}
while (commandIndex < ResultSetEnds.Count
&& await reader.NextResultAsync(cancellationToken));
Debug.Assert(commandIndex == ModificationCommands.Count, "Expected " + ModificationCommands.Count + " results, got " + commandIndex);
#if DEBUG
var expectedResultSetCount = 1 + ResultSetEnds.Count(e => e);
expectedResultSetCount += ResultSetEnds[ResultSetEnds.Count - 1] ? -1 : 0;
Debug.Assert(actualResultSetCount == expectedResultSetCount, "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
#endif
}
catch (DbUpdateException)
{
throw;
}
catch (Exception ex)
{
throw new DbUpdateException(
Strings.UpdateStoreException,
ex,
ModificationCommands[commandIndex].Entries);
}
}
示例5: ConsumeAsync
protected override async Task ConsumeAsync(
DbDataReader reader,
CancellationToken cancellationToken = default(CancellationToken))
{
Debug.Assert(CommandResultSet.Count == ModificationCommands.Count);
var commandIndex = 0;
try
{
var actualResultSetCount = 0;
do
{
while (commandIndex < CommandResultSet.Count
&& CommandResultSet[commandIndex] == ResultSetMapping.NoResultSet)
{
commandIndex++;
}
if (commandIndex < CommandResultSet.Count)
{
commandIndex = ModificationCommands[commandIndex].RequiresResultPropagation
? await ConsumeResultSetWithPropagationAsync(commandIndex, reader, cancellationToken)
: await ConsumeResultSetWithoutPropagationAsync(commandIndex, reader, cancellationToken);
actualResultSetCount++;
}
}
while (commandIndex < CommandResultSet.Count
&& await reader.NextResultAsync(cancellationToken));
#if DEBUG
while (commandIndex < CommandResultSet.Count
&& CommandResultSet[commandIndex] == ResultSetMapping.NoResultSet)
{
commandIndex++;
}
Debug.Assert(commandIndex == ModificationCommands.Count,
"Expected " + ModificationCommands.Count + " results, got " + commandIndex);
var expectedResultSetCount = CommandResultSet.Count(e => e == ResultSetMapping.LastInResultSet);
Debug.Assert(actualResultSetCount == expectedResultSetCount,
"Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount);
#endif
}
catch (DbUpdateException)
{
throw;
}
catch (Exception ex)
{
throw new DbUpdateException(
RelationalStrings.UpdateStoreException,
ex,
ModificationCommands[commandIndex].Entries);
}
}
示例6: 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);
}