Table of Contents

Method Single

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

Single<T>(IDbCommand, Func<IDataRecord, T>, CommandBehavior)

Iterates an IDataReader and returns the first result through a transform function.

public static T Single<T>(this IDbCommand command, Func<IDataRecord, T> transform, CommandBehavior behavior = CommandBehavior.Default)

Parameters

command IDbCommand

The IDbCommand to generate a reader from.

transform Func<IDataRecord, T>

The transform function to process each IDataRecord.

behavior CommandBehavior

The behavior to use with the data reader.

Returns

T

The value from the transform.

Type Parameters

T

The return type of the transform function.

Remarks

Throws an InvalidOperationException if there is anything other than a single result.