コード例 #1
0
ファイル: IDbCmdExtensions.cs プロジェクト: deipax/Deipax
        /// <summary>
        /// Either read all items or use a using block to ensure all
        /// resources are fully cleaned up.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static IManagedEnumerable <T> AsEnumerable <T>(
            this IDbCmd source) where T : new()
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            source.CommandBehavior(CmdBehavior.SingleResult);
            var cmd    = source.CreateAndOpen();
            var reader = cmd.ExecuteReader(source);

            return(new ManagedEnumerable <T>(source, cmd, reader));
        }
コード例 #2
0
ファイル: IDbCmdExtensions.cs プロジェクト: deipax/Deipax
        /// <summary>
        /// Either read all items or use a using block to ensure all
        /// resources are fully cleaned up.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static async Task <IManagedEnumerable <T> > AsEnumerableAsync <T>(
            this IDbCmd source) where T : new()
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            source.CommandBehavior(CmdBehavior.SingleResult);
            var cmd = await source.CreateAndOpenAsync().ConfigureAwait(false);

            var reader = await cmd.ExecuteReaderAsync(source).ConfigureAwait(false);

            return(new ManagedEnumerable <T>(source, cmd, reader));
        }