Table of Contents

Method ExecuteReader

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

ExecuteReader<TReader>(IExecuteReader<TReader>, Action<TReader>, CommandBehavior)

Executes a reader and passes it to the handler.

public static void ExecuteReader<TReader>(this IExecuteReader<TReader> command, Action<TReader> handler, CommandBehavior behavior = CommandBehavior.Default) where TReader : IDataReader

Parameters

command IExecuteReader<TReader>

The command to execute.

handler Action<TReader>

The function that uses the reader.

behavior CommandBehavior

The command behavior.

Type Parameters

TReader

The type of reader.

Exceptions

ArgumentNullException

handler is null.

ExecuteReader<TReader, T>(IExecuteReader<TReader>, Func<TReader, T>, CommandBehavior)

Executes a reader, passes it to the transform and returns the result.

public static T ExecuteReader<TReader, T>(this IExecuteReader<TReader> command, Func<TReader, T> transform, CommandBehavior behavior = CommandBehavior.Default) where TReader : IDataReader

Parameters

command IExecuteReader<TReader>

The command to execute.

transform Func<TReader, T>

The function that uses the reader.

behavior CommandBehavior

The command behavior.

Returns

T

The value returned from the transform.

Type Parameters

TReader

The type of reader.

T

The type returned.

Exceptions

ArgumentNullException

transform is null.

ExecuteReader<TState, TResult>(IExecuteReader, TState, Func<IDataReader, TState, TResult>, CommandBehavior)

Executes a reader, passes it and a state to the transform and returns the result.

public static TResult ExecuteReader<TState, TResult>(this IExecuteReader command, TState state, Func<IDataReader, TState, TResult> transform, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IExecuteReader

The command to execute.

state TState

The state to pass to the transform.

transform Func<IDataReader, TState, TResult>

The function that uses the reader.

behavior CommandBehavior

The command behavior.

Returns

TResult

The value returned from the transform.

Type Parameters

TState

The type of the state.

TResult

The type returned.

Exceptions

ArgumentNullException

transform is null.

ExecuteReader(IExecuteReader, Action<IDataReader>, CommandBehavior)

Executes a reader and passes it to the handler.

public static void ExecuteReader(this IExecuteReader command, Action<IDataReader> handler, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IExecuteReader

The command to execute.

handler Action<IDataReader>

The function that uses the reader.

behavior CommandBehavior

The command behavior.

Exceptions

ArgumentNullException

command or handler is null.

NotSupportedException

The command does not support blocking calls; use the async call.

ExecuteReader<T>(IExecuteReader, Func<IDataReader, T>, CommandBehavior)

Executes a reader, passes it to the transform and returns the result.

public static T ExecuteReader<T>(this IExecuteReader command, Func<IDataReader, T> transform, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IExecuteReader

The command to execute.

transform Func<IDataReader, T>

The function that uses the reader.

behavior CommandBehavior

The command behavior.

Returns

T

The value returned from the transform.

Type Parameters

T

The type returned.

Exceptions

ArgumentNullException

command or transform is null.

NotSupportedException

The command does not support blocking calls; use the async call.