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
commandIDbCommandThe IDbCommand to generate a reader from.
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.
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
commandIDbCommandThe IDbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
transformFunc<IDataRecord, TEntity>The transform function for each IDataRecord.
selectorFunc<IEnumerable<TEntity>, TResult>Provides an IEnumerable<TEntity> to select individual results by.
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.
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
commandIDbCommandThe IDbCommand to generate a reader from.
behaviorCommandBehaviorThe behavior to use with the data reader.
handlerAction<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
commandIDbCommandThe IDbCommand to generate a reader from.
handlerAction<IDataRecord>The handler function for each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.