Table of Contents

Method ReaderBehavior

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

ReaderBehavior(CommandBehavior)

The behavior to execute a reader with: behavior, plus CloseConnection when this scope opened the connection.

public CommandBehavior ReaderBehavior(CommandBehavior behavior = CommandBehavior.Default)

Parameters

behavior CommandBehavior

The behavior to start from. The default is Default.

Returns

CommandBehavior

The behavior to pass to the command.

Remarks

A reader that outlives the scope still closes what the scope opened, because the connection closes when the reader does:

var scope = await connection.EnsureOpenScopeAsync(cancellationToken).ConfigureAwait(false);
await using var disposal = scope.ConfigureAwait(false);
await using var reader = await command
    .ExecuteReaderAsync(scope.ReaderBehavior(), cancellationToken)
    .ConfigureAwait(false);

A connection that was already open is left open: nothing is added. A default scope opened nothing, so it adds nothing either.