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
commandIExecuteReaderThe IExecuteReader to iterate.
handlerAction<IDataRecord>The handler function for each IDataRecord.
behaviorCommandBehaviorThe 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
commandIExecuteReaderThe IExecuteReader to iterate.
transformFunc<IDataRecord, TEntity>The transform function for each IDataRecord.
selectorFunc<IEnumerable<TEntity>, TResult>Provides an IEnumerable<TEntity> to select individual results by.
behaviorCommandBehaviorThe behavior to use with the data reader.
Returns
- TResult
The result of the transform.
Type Parameters
TEntityThe return type of the transform function applied to each record.
TResultThe type returned by the selector.