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 !;
Example #2
0
    public partial global::SomeType WithEncryptionSystemSql(global::System.Data.SqlClient.SqlConnection connection, int id, string name)
    {
        // locals
        global::System.Data.SqlClient.SqlCommand?   __dapper__command = null;
        global::System.Data.SqlClient.SqlDataReader?__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_CustomOptions_input_cs_WithEncryptionSystemSql_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 = __dapper__command.ExecuteReader(__dapper__close ? (__dapper__behavior | global::System.Data.CommandBehavior.CloseConnection) : __dapper__behavior);
            __dapper__close  = false;            // performed via CommandBehavior

            // process single row
            global::SomeType __dapper__result;
            if (__dapper__reader.HasRows && __dapper__reader.Read())
            {
                __dapper__result = global::Dapper.TypeReader.TryGetReader <global::SomeType>() !.Read(__dapper__reader, ref __dapper__tokenBuffer);
            }
            else
            {
                __dapper__result = default !;
Example #3
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 !;
    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();
            }
        }
Example #5
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();
                }
            }
        }