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


C# DbDataReader.NextResultAsync方法代码示例

本文整理汇总了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);
        }
开发者ID:nieve,项目名称:marten,代码行数:11,代码来源:DataReaderAdvancer.cs

示例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)
         }
     }
 }
开发者ID:jwanagel,项目名称:jjwtest,代码行数:17,代码来源:CommandHelper.cs

示例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)
                }
            }
        }
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:21,代码来源:CommandHelper.cs

示例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);
            }
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:41,代码来源:AffectedCountModificationCommandBatch.cs

示例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);
            }
        }
开发者ID:RickyLin,项目名称:EntityFramework,代码行数:57,代码来源:AffectedCountModificationCommandBatch.cs

示例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);
        }
开发者ID:JasperFx,项目名称:marten,代码行数:14,代码来源:Fetcher.cs


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