Table of Contents

Method IterateReader

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

IterateReader(IExecuteReader, Action<IDataRecord>, CommandBehavior)

Iterates a reader on a command with a handler function.

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

Parameters

command IExecuteReader

The IExecuteReader to iterate.

handler Action<IDataRecord>

The handler function for each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

IterateReader<TEntity, TResult>(IExecuteReader, 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 IExecuteReader command, Func<IDataRecord, TEntity> transform, Func<IEnumerable<TEntity>, TResult> selector, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IExecuteReader

The IExecuteReader to iterate.

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.