Table of Contents

Method First

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

First<T>(MappedQuery<T>)

Reads the first mapped row; throws if the query returns no rows.

public static T First<T>(this MappedQuery<T> query)

Parameters

query MappedQuery<T>

The query to execute.

Returns

T

The first row.

Type Parameters

T

The type each row is mapped to.

Remarks

Rows after the first are not mapped. Add an ORDER BY to the SQL when "first" must be deterministic.

A row whose value is NULL is still a row, and default is returned for it.

The no-rows error is thrown after the command has been cleaned up: the connection is released and, unless SingleResult() was called, the later result sets have been read through, so a failure in one of them is thrown instead.

Exceptions

ArgumentNullException

query is null.

InvalidOperationException

The query returns no rows.

See Also
FirstOrDefault()
Single()

First<T>(MappedQueryWithSkip<T>)

Reads the first mapped row; throws if the query returns no rows.

public static T First<T>(this MappedQueryWithSkip<T> query)

Parameters

query MappedQueryWithSkip<T>

The query to execute.

Returns

T

The first row.

Type Parameters

T

The type each row is mapped to.

Remarks

Rows after the first are not mapped. Add an ORDER BY to the SQL when "first" must be deterministic.

A row whose value is NULL is still a row, and default is returned for it.

The no-rows error is thrown after the command has been cleaned up: the connection is released and, unless SingleResult() was called, the later result sets have been read through, so a failure in one of them is thrown instead.

Exceptions

ArgumentNullException

query is null.

InvalidOperationException

The query returns no rows.

See Also
FirstOrDefault()
Single()

First<T>(MappedQueryWithTake<T>)

Reads the first mapped row; throws if the query returns no rows.

public static T First<T>(this MappedQueryWithTake<T> query)

Parameters

query MappedQueryWithTake<T>

The query to execute.

Returns

T

The first row.

Type Parameters

T

The type each row is mapped to.

Remarks

Rows after the first are not mapped. Add an ORDER BY to the SQL when "first" must be deterministic.

A row whose value is NULL is still a row, and default is returned for it.

The no-rows error is thrown after the command has been cleaned up: the connection is released and, unless SingleResult() was called, the later result sets have been read through, so a failure in one of them is thrown instead.

Exceptions

ArgumentNullException

query is null.

InvalidOperationException

The query returns no rows.

See Also
FirstOrDefault()
Single()

First<T>(MappedCommand<T>)

Reads the first mapped row; throws if the query returns no rows.

public static T First<T>(this MappedCommand<T> query)

Parameters

query MappedCommand<T>

The query to execute.

Returns

T

The first row.

Type Parameters

T

The type each row is mapped to.

Remarks

Rows after the first are not mapped. Add an ORDER BY to the SQL when "first" must be deterministic.

A row whose value is NULL is still a row, and default is returned for it.

The no-rows error is thrown after the command has been cleaned up: the connection is released and, unless SingleResult() was called, the later result sets have been read through, so a failure in one of them is thrown instead.

Exceptions

ArgumentNullException

query is null.

InvalidOperationException

The query returns no rows.

See Also
FirstOrDefault()
Single()