コード例 #1
0
ファイル: IDbCmdExtensions.cs プロジェクト: deipax/Deipax
        private static IDbCommand CreateAndOpen(
            this IDbCmd source)
        {
            var cmd = source.CreateCommand();

            cmd.Connection.EnsureOpen();
            return(cmd);
        }
コード例 #2
0
ファイル: IDbCmdExtensions.cs プロジェクト: deipax/Deipax
        internal static async Task <DbCommand> CreateAndOpenAsync(
            this IDbCmd source)
        {
            var cmd = source.CreateCommand();
            await cmd.Connection.EnsureOpenAsync(source.CancellationToken).ConfigureAwait(false);

            if (cmd is DbCommand dbCommand)
            {
                return(dbCommand);
            }
            else
            {
                throw new InvalidOperationException("Async operations require use of a DbCommand");
            }
        }