Example #1
0
        private static IDbCommand CreateAndOpen(
            this IDbCmd source)
        {
            var cmd = source.CreateCommand();

            cmd.Connection.EnsureOpen();
            return(cmd);
        }
Example #2
0
        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");
            }
        }