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
commandIDbCommandThe IDbCommand to generate a reader from.
handlerAction<IDataReader>The handler function for each IDataRecord.
behaviorCommandBehaviorThe 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
commandIDbCommandThe IDbCommand to generate a reader from.
transformFunc<IDataReader, T>The transform function for each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.
Returns
- T
The result of the transform.
Type Parameters
TThe 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.