Table of Contents

Method IterateReader

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

IterateReader<TEntity, TResult>(IDbCommand, Func<IDataRecord, TEntity>, Func<IEnumerable<TEntity>, TResult>, CommandBehavior)

Executes a reader on a command with a transform function.

public static TResult IterateReader<TEntity, TResult>(this IDbCommand command, Func<IDataRecord, TEntity> transform, Func<IEnumerable<TEntity>, TResult> selector, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

transform Func<IDataRecord, TEntity>

The transform function for each IDataRecord.

selector Func<IEnumerable<TEntity>, TResult>

Provides an IEnumerable<TEntity> to select individual results by.

behavior CommandBehavior

The behavior to use with the data reader.

Returns

TResult

The result of the transform.

Type Parameters

TEntity

The return type of the transform function applied to each record.

TResult

The type returned by the selector.

Remarks

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

IterateReader<TEntity, TResult>(IDbCommand, CommandBehavior, Func<IDataRecord, TEntity>, Func<IEnumerable<TEntity>, TResult>)

Executes a reader on a command with a transform function.

public static TResult IterateReader<TEntity, TResult>(this IDbCommand command, CommandBehavior behavior, Func<IDataRecord, TEntity> transform, Func<IEnumerable<TEntity>, TResult> selector)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader.

transform Func<IDataRecord, TEntity>

The transform function for each IDataRecord.

selector Func<IEnumerable<TEntity>, TResult>

Provides an IEnumerable<TEntity> to select individual results by.

Returns

TResult

The result of the transform.

Type Parameters

TEntity

The return type of the transform function applied to each record.

TResult

The type returned by the selector.

Remarks

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

IterateReader(IDbCommand, CommandBehavior, Action<IDataRecord>)

Iterates an IDataReader on a command with a handler function.

public static void IterateReader(this IDbCommand command, CommandBehavior behavior, Action<IDataRecord> handler)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

behavior CommandBehavior

The behavior to use with the data reader.

handler Action<IDataRecord>

The handler function for each IDataRecord.

IterateReader(IDbCommand, Action<IDataRecord>, CommandBehavior)

Iterates an IDataReader on a command with a handler function.

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

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

handler Action<IDataRecord>

The handler function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.