Method ExecuteReader
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ExecuteReader<TState, TResult>(TState, Func<IDataReader, TState, TResult>, CommandBehavior)
Executes a reader on a command, passing state to transform.
Pass a static lambda and the state it needs to avoid allocating a closure per call.
public TResult ExecuteReader<TState, TResult>(TState state, Func<IDataReader, TState, TResult> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
stateTStateThe state to pass to the transform.
transformFunc<IDataReader, TState, TResult>The transform function for the data reader.
behaviorCommandBehaviorThe command behavior for once the command the reader is complete.
Returns
- TResult
The result of the transform.
Type Parameters
TStateThe type of the state passed to the transform.
TResultThe return type of the transform function.
ExecuteReader(Action<TReader>, CommandBehavior)
Executes a reader on a command with a handler function.
public void ExecuteReader(Action<TReader> handler, CommandBehavior behavior = CommandBehavior.Default)
Parameters
handlerAction<TReader>The handler function for the data reader.
behaviorCommandBehaviorThe command behavior for once the command the reader is complete.
ExecuteReader<T>(Func<TReader, T>, CommandBehavior)
Executes a reader on a command with a transform function.
public T ExecuteReader<T>(Func<TReader, T> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
transformFunc<TReader, T>The transform function for each IDataRecord.
behaviorCommandBehaviorThe command behavior for once the command the reader is complete.
Returns
- T
The result of the transform.
Type Parameters
TThe return type of the transform function.