Method First
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
First<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)
Iterates an IDataReader and returns the first result through a transform function.
public static T First<T>(this IDbCommand command, Func<IDataRecord, T> transform, CommandBehavior behavior = CommandBehavior.Default)
Parameters
commandIDbCommandThe IDbCommand to generate a reader from.
transformFunc<IDataRecord, T>The transform function to process each IDataRecord.
behaviorCommandBehaviorThe behavior to use with the data reader.
Returns
- T
The value from the transform.
Type Parameters
TThe return type of the transform function.
Remarks
Throws an InvalidOperationException if there are no results.