Method ExecuteReader
- Namespace
- Open.Database.Extensions.Synchronous
- Assembly
- Open.Database.Extensions.Core.dll
ExecuteReader<TReader>(IExecuteReader<TReader>, Action<TReader>, CommandBehavior)
Executes a reader and passes it to the handler.
public static void ExecuteReader<TReader>(this IExecuteReader<TReader> command, Action<TReader> handler, CommandBehavior behavior = CommandBehavior.Default) where TReader : IDataReader
Parameters
commandIExecuteReader<TReader>The command to execute.
handlerAction<TReader>The function that uses the reader.
behaviorCommandBehaviorThe command behavior.
Type Parameters
TReaderThe type of reader.
Exceptions
- ArgumentNullException
handleris null.
ExecuteReader<TReader, T>(IExecuteReader<TReader>, Func<TReader, T>, CommandBehavior)
Executes a reader, passes it to the transform and returns the result.
public static T ExecuteReader<TReader, T>(this IExecuteReader<TReader> command, Func<TReader, T> transform, CommandBehavior behavior = CommandBehavior.Default) where TReader : IDataReader
Parameters
commandIExecuteReader<TReader>The command to execute.
transformFunc<TReader, T>The function that uses the reader.
behaviorCommandBehaviorThe command behavior.
Returns
- T
The value returned from the transform.
Type Parameters
TReaderThe type of reader.
TThe type returned.
Exceptions
- ArgumentNullException
transformis null.
ExecuteReader<TState, TResult>(IExecuteReader, TState, Func<IDataReader, TState, TResult>, CommandBehavior)
Executes a reader, passes it and a state to the transform and returns the result.
public static TResult ExecuteReader<TState, TResult>(this IExecuteReader command, TState state, Func<IDataReader, TState, TResult> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
commandIExecuteReaderThe command to execute.
stateTStateThe state to pass to the transform.
transformFunc<IDataReader, TState, TResult>The function that uses the reader.
behaviorCommandBehaviorThe command behavior.
Returns
- TResult
The value returned from the transform.
Type Parameters
TStateThe type of the state.
TResultThe type returned.
Exceptions
- ArgumentNullException
transformis null.
ExecuteReader(IExecuteReader, Action<IDataReader>, CommandBehavior)
Executes a reader and passes it to the handler.
public static void ExecuteReader(this IExecuteReader command, Action<IDataReader> handler, CommandBehavior behavior = CommandBehavior.Default)
Parameters
commandIExecuteReaderThe command to execute.
handlerAction<IDataReader>The function that uses the reader.
behaviorCommandBehaviorThe command behavior.
Exceptions
- ArgumentNullException
commandorhandleris null.- NotSupportedException
The command does not support blocking calls; use the async call.
ExecuteReader<T>(IExecuteReader, Func<IDataReader, T>, CommandBehavior)
Executes a reader, passes it to the transform and returns the result.
public static T ExecuteReader<T>(this IExecuteReader command, Func<IDataReader, T> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
commandIExecuteReaderThe command to execute.
transformFunc<IDataReader, T>The function that uses the reader.
behaviorCommandBehaviorThe command behavior.
Returns
- T
The value returned from the transform.
Type Parameters
TThe type returned.
Exceptions
- ArgumentNullException
commandortransformis null.- NotSupportedException
The command does not support blocking calls; use the async call.