Table of Contents

Method ExecuteReader

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

ExecuteReader(IDbCommand, Action<IDataReader>, CommandBehavior)

Executes a reader on a command with a handler function.

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

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

handler Action<IDataReader>

The handler function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

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

Executes a reader on a command with a transform function.

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

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

transform Func<IDataReader, T>

The transform function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

Returns

T

The result of the transform.

Type Parameters

T

The return type of the transform function.

Remarks

The default behavior will open a connection, execute the reader and close the connection it if was not already open.