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
queryMappedQuery<T>The query to execute.
Returns
- T
The first row.
Type Parameters
TThe 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
queryis 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
queryMappedQueryWithSkip<T>The query to execute.
Returns
- T
The first row.
Type Parameters
TThe 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
queryis 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
queryMappedQueryWithTake<T>The query to execute.
Returns
- T
The first row.
Type Parameters
TThe 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
queryis 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
queryMappedCommand<T>The query to execute.
Returns
- T
The first row.
Type Parameters
TThe 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
queryis null.- InvalidOperationException
The query returns no rows.
- See Also
-
FirstOrDefault()Single()