Esempio n. 1
0
    public async partial global::System.Threading.Tasks.Task TaskAsync(global::System.Data.Common.DbConnection connection, int id, string name)
    {
        // locals
        global::System.Data.Common.DbCommand?__dapper__command = null;
        bool __dapper__close = false;

        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                await connection !.OpenAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false);
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_NonQuery_input_cs_TaskAsync_8, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
            __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(name);
#pragma warning restore CS0618

            // execute non-query
            await __dapper__command.ExecuteNonQueryAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false);

            // TODO: post-process parameters
        }
        finally
        {
            // cleanup
            if (__dapper__command is not null)
            {
                __dapper__command.Connection = default;
                __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_NonQuery_input_cs_TaskAsync_8, __dapper__command);
                if (__dapper__command is not null)
                {
                    await __dapper__command.DisposeAsync().ConfigureAwait(false);
                }
            }
            if (__dapper__close)
            {
                await(connection?.CloseAsync() ?? global::System.Threading.Tasks.Task.CompletedTask).ConfigureAwait(false);
            }
        }
Esempio n. 2
0
    public partial int ReturnViaReturn(global::System.Data.Common.DbConnection connection, int id, string inputOutput, global::System.DateTime output)
    {
        // locals
        global::System.Data.Common.DbCommand?__dapper__command = null;
        bool __dapper__close = false;

        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                connection !.Open();
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Sync_Parameters_input_cs_ReturnViaReturn_9, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
            __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(inputOutput);
            __dapper__command.Parameters[2].Value = global::Dapper.Internal.InternalUtilities.AsValue(output);
#pragma warning restore CS0618

            // execute non-query
            __dapper__command.ExecuteNonQuery();

            // TODO: post-process parameters
        }
        finally
        {
            // cleanup
            if (__dapper__command is not null)
            {
                __dapper__command.Connection = default;
                __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Sync_Parameters_input_cs_ReturnViaReturn_9, __dapper__command);
                __dapper__command?.Dispose();
            }
            if (__dapper__close)
            {
                connection?.Close();
            }
        }
    public async partial global::PooledAwait.PooledTask <global::SomeType> TaskAsync(global::System.Data.Common.DbConnection connection, int id, string name)
    {
        // locals
        global::System.Data.Common.DbCommand?   __dapper__command = null;
        global::System.Data.Common.DbDataReader?__dapper__reader  = null;
        bool __dapper__close = false;

        int[]? __dapper__tokenBuffer = null;
        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                await connection !.OpenAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false);
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_SinglePooled_input_cs_TaskAsync_8, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
            __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(name);
#pragma warning restore CS0618

            // execute reader
            const global::System.Data.CommandBehavior __dapper__behavior = global::System.Data.CommandBehavior.SequentialAccess | global::System.Data.CommandBehavior.SingleResult | global::System.Data.CommandBehavior.SingleRow;
            __dapper__reader = await __dapper__command.ExecuteReaderAsync(__dapper__close?(__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior, global::System.Threading.CancellationToken.None).ConfigureAwait(false);

            __dapper__close = false;             // performed via CommandBehavior

            // process single row
            global::SomeType __dapper__result;
            if (__dapper__reader.HasRows && await __dapper__reader.ReadAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false))
            {
                __dapper__result = await global::Dapper.TypeReader.TryGetReader <global::SomeType>() !.ReadAsync(__dapper__reader, ref __dapper__tokenBuffer, global::System.Threading.CancellationToken.None).ConfigureAwait(false);
            }
            else
            {
                __dapper__result = default !;
    public async partial global::System.Threading.Tasks.ValueTask <int> ReturnViaReturnAsync(global::System.Data.Common.DbConnection connection, global::Test.FooParams parameters)
    {
        // locals
        global::System.Data.Common.DbCommand?__dapper__command = null;
        bool __dapper__close = false;

        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                await connection !.OpenAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false);
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_Parameters_input_cs_ReturnViaReturnAsync_19, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(parameters);
#pragma warning restore CS0618

            // execute non-query
            await __dapper__command.ExecuteNonQueryAsync(global::System.Threading.CancellationToken.None).ConfigureAwait(false);
        }
        finally
        {
            // cleanup
            if (__dapper__command is not null)
            {
                __dapper__command.Connection = default;
                __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_Parameters_input_cs_ReturnViaReturnAsync_19, __dapper__command);
                __dapper__command?.Dispose();
            }
            if (__dapper__close)
            {
                connection?.Close();
            }
        }
Esempio n. 5
0
    public partial global::System.Collections.Generic.List <global::SomeType> ImplicitCommandText(global::System.Data.Common.DbConnection connection, int id, string name)
    {
        // locals
        global::System.Data.Common.DbCommand?   __dapper__command = null;
        global::System.Data.Common.DbDataReader?__dapper__reader  = null;
        bool __dapper__close = false;

        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                connection !.Open();
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Commands_input_cs_ImplicitCommandText_14, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
            __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(name);
#pragma warning restore CS0618

            // execute reader
            const global::System.Data.CommandBehavior __dapper__behavior = global::System.Data.CommandBehavior.SequentialAccess | global::System.Data.CommandBehavior.SingleResult | global::System.Data.CommandBehavior.SingleRow;
            __dapper__reader = __dapper__command.ExecuteReader(__dapper__close ? (__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior);
            __dapper__close  = false;            // performed via CommandBehavior

            // process single row
            global::System.Collections.Generic.List <global::SomeType> __dapper__result;
            if (__dapper__reader.HasRows && __dapper__reader.Read())
            {
                __dapper__result = global::Dapper.SqlMapper.GetRowParser <global::System.Collections.Generic.List <global::SomeType> >(__dapper__reader).Invoke(__dapper__reader);
            }
            else
            {
                __dapper__result = default !;
Esempio n. 6
0
    public partial int?ShouldDetectThis(global::System.Data.Common.DbConnection connection, string region)
    {
        // locals
        global::System.Data.Common.DbCommand?   __dapper__command = null;
        global::System.Data.Common.DbDataReader?__dapper__reader  = null;
        bool __dapper__close = false;

        int[]? __dapper__tokenBuffer = null;
        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                connection !.Open();
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Basic_input_cs_ShouldDetectThis_11, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(region);
#pragma warning restore CS0618

            // execute reader
            const global::System.Data.CommandBehavior __dapper__behavior = global::System.Data.CommandBehavior.SequentialAccess | global::System.Data.CommandBehavior.SingleResult | global::System.Data.CommandBehavior.SingleRow;
            __dapper__reader = __dapper__command.ExecuteReader(__dapper__close ? (__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior);
            __dapper__close  = false;            // performed via CommandBehavior

            // process single row
            int?__dapper__result;
            if (__dapper__reader.HasRows && __dapper__reader.Read())
            {
                __dapper__result = global::Dapper.TypeReader.TryGetReader <int?>() !.Read(__dapper__reader, ref __dapper__tokenBuffer);
            }
            else
            {
                __dapper__result = default !;
Esempio n. 7
0
    public partial void Abstract(global::System.Data.Common.DbConnection connection)
    {
        // locals
        global::System.Data.Common.DbCommand?__dapper__command = null;
        bool __dapper__close = false;

        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                connection !.Open();
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Transactions_input_cs_Abstract_9, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // execute non-query
            __dapper__command.ExecuteNonQuery();

            // TODO: post-process parameters
        }
        finally
        {
            // cleanup
            if (__dapper__command is not null)
            {
                __dapper__command.Connection = default;
                __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Transactions_input_cs_Abstract_9, __dapper__command);
                __dapper__command?.Dispose();
            }
            if (__dapper__close)
            {
                connection?.Close();
            }
        }
    public partial global::System.Collections.Generic.IEnumerable <global::SomeType> Sequence(global::System.Data.Common.DbConnection connection, int id, string name)
    {
        // locals
        global::System.Data.Common.DbCommand?   __dapper__command = null;
        global::System.Data.Common.DbDataReader?__dapper__reader  = null;
        bool __dapper__close = false;

        int[]? __dapper__tokenBuffer = null;
        try
        {
            // prepare connection
            if (connection !.State == global::System.Data.ConnectionState.Closed)
            {
                connection !.Open();
                __dapper__close = true;
            }

            // prepare command (excluding parameter values)
            if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Sync_Sequence_input_cs_Sequence_7, null)) is null)
            {
                __dapper__command = __dapper__CreateCommand(connection !);
            }
            else
            {
                __dapper__command.Connection = connection;
            }

            // assign parameter values
#pragma warning disable CS0618
            __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
            __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(name);
#pragma warning restore CS0618

            // execute reader
            const global::System.Data.CommandBehavior __dapper__behavior = global::System.Data.CommandBehavior.SequentialAccess | global::System.Data.CommandBehavior.SingleResult | global::System.Data.CommandBehavior.SingleRow;
            __dapper__reader = __dapper__command.ExecuteReader(__dapper__close ? (__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior);
            __dapper__close  = false;            // performed via CommandBehavior

            // process multiple rows
            if (__dapper__reader.HasRows)
            {
                var __dapper__parser = global::Dapper.TypeReader.TryGetReader <global::SomeType>() !;
                global::System.Span <int> __dapper__tokens = __dapper__reader.FieldCount <= global::Dapper.TypeReader.MaxStackTokens ? stackalloc int[__dapper__reader.FieldCount] : global::Dapper.TypeReader.RentSpan(ref __dapper__tokenBuffer, __dapper__reader.FieldCount);
                __dapper__parser.IdentifyFieldTokensFromSchema(__dapper__reader, __dapper__tokens);
                while (__dapper__reader.Read())
                {
                    yield return(__dapper__parser.Read(__dapper__reader, __dapper__tokens));
                }
            }
            // consume additional results (ensures errors from the server are observed)
            while (__dapper__reader.NextResult())
            {
            }

            // TODO: post-process parameters
        }
        finally
        {
            // cleanup
            global::Dapper.TypeReader.Return(ref __dapper__tokenBuffer);
            __dapper__reader?.Dispose();
            if (__dapper__command is not null)
            {
                __dapper__command.Connection = default;
                __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Sync_Sequence_input_cs_Sequence_7, __dapper__command);
                __dapper__command?.Dispose();
            }
            if (__dapper__close)
            {
                connection?.Close();
            }
        }
Esempio n. 9
0
        static async global::System.Collections.Generic.IAsyncEnumerable <global::SomeType> __dapper__SequenceAsync(global::System.Data.Common.DbConnection connection, int id, string name, [global::System.Runtime.CompilerServices.EnumeratorCancellationAttribute] global::System.Threading.CancellationToken __dapper__cancellation)
        {
            // locals
            global::System.Data.Common.DbCommand?   __dapper__command = null;
            global::System.Data.Common.DbDataReader?__dapper__reader  = null;
            bool __dapper__close = false;

            int[]? __dapper__tokenBuffer = null;
            try
            {
                // prepare connection
                if (connection !.State == global::System.Data.ConnectionState.Closed)
                {
                    await connection !.OpenAsync(__dapper__cancellation).ConfigureAwait(false);
                    __dapper__close = true;
                }

                // prepare command (excluding parameter values)
                if ((__dapper__command = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_Sequence_input_cs_SequenceAsync_8, null)) is null)
                {
                    __dapper__command = __dapper__CreateCommand(connection !);
                }
                else
                {
                    __dapper__command.Connection = connection;
                }

                // assign parameter values
#pragma warning disable CS0618
                __dapper__command.Parameters[0].Value = global::Dapper.Internal.InternalUtilities.AsValue(id);
                __dapper__command.Parameters[1].Value = global::Dapper.Internal.InternalUtilities.AsValue(name);
#pragma warning restore CS0618

                // execute reader
                const global::System.Data.CommandBehavior __dapper__behavior = global::System.Data.CommandBehavior.SequentialAccess | global::System.Data.CommandBehavior.SingleResult | global::System.Data.CommandBehavior.SingleRow;
                __dapper__reader = await __dapper__command.ExecuteReaderAsync(__dapper__close?(__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior, __dapper__cancellation).ConfigureAwait(false);

                __dapper__close = false;                 // performed via CommandBehavior

                // process multiple rows
                if (__dapper__reader.HasRows)
                {
                    var __dapper__parser = global::Dapper.TypeReader.TryGetReader <global::SomeType>() !;
                    var __dapper__tokens = global::Dapper.TypeReader.RentSegment(ref __dapper__tokenBuffer, __dapper__reader.FieldCount);
                    __dapper__parser.IdentifyFieldTokensFromSchema(__dapper__reader, __dapper__tokens);
                    while (await __dapper__reader.ReadAsync(__dapper__cancellation).ConfigureAwait(false))
                    {
                        yield return(await __dapper__parser.ReadAsync(__dapper__reader, __dapper__tokens, __dapper__cancellation).ConfigureAwait(false));
                    }
                }
                // consume additional results (ensures errors from the server are observed)
                while (await __dapper__reader.NextResultAsync(__dapper__cancellation).ConfigureAwait(false))
                {
                }

                // TODO: post-process parameters
            }
            finally
            {
                // cleanup
                global::Dapper.TypeReader.Return(ref __dapper__tokenBuffer);
                __dapper__reader?.Dispose();
                if (__dapper__command is not null)
                {
                    __dapper__command.Connection = default;
                    __dapper__command            = global::System.Threading.Interlocked.Exchange(ref s___dapper__command_Samples_Async_Sequence_input_cs_SequenceAsync_8, __dapper__command);
                    __dapper__command?.Dispose();
                }
                if (__dapper__close)
                {
                    connection?.Close();
                }
            }
        }