Method Single
- Namespace
- Open.Database.Extensions.Synchronous
- Assembly
- Open.Database.Extensions.Core.dll
Single<T>(MappedQuery<T>)
Reads the only mapped row; throws if the query returns no rows or more than one.
public static T Single<T>(this MappedQuery<T> query)
Parameters
queryMappedQuery<T>The query to execute.
Returns
- T
The single row.
Type Parameters
TThe type each row is mapped to.
Remarks
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.
The more-than-one error is thrown at the second row, before the later result sets are read, so it is never replaced by a later failure.
Exceptions
- ArgumentNullException
queryis null.- InvalidOperationException
The query returns no rows, or more than one row.
- See Also
-
SingleOrDefault()First()
Single<T>(MappedQueryWithSkip<T>)
Reads the only mapped row; throws if the query returns no rows or more than one.
public static T Single<T>(this MappedQueryWithSkip<T> query)
Parameters
queryMappedQueryWithSkip<T>The query to execute.
Returns
- T
The single row.
Type Parameters
TThe type each row is mapped to.
Remarks
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.
The more-than-one error is thrown at the second row, before the later result sets are read, so it is never replaced by a later failure.
Exceptions
- ArgumentNullException
queryis null.- InvalidOperationException
The query returns no rows, or more than one row.
- See Also
-
SingleOrDefault()First()
Single<T>(MappedQueryWithTake<T>)
Reads the only mapped row; throws if the query returns no rows or more than one.
public static T Single<T>(this MappedQueryWithTake<T> query)
Parameters
queryMappedQueryWithTake<T>The query to execute.
Returns
- T
The single row.
Type Parameters
TThe type each row is mapped to.
Remarks
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.
The more-than-one error is thrown at the second row, before the later result sets are read, so it is never replaced by a later failure.
Exceptions
- ArgumentNullException
queryis null.- InvalidOperationException
The query returns no rows, or more than one row.
- See Also
-
SingleOrDefault()First()
Single<T>(MappedCommand<T>)
Reads the only mapped row; throws if the query returns no rows or more than one.
public static T Single<T>(this MappedCommand<T> query)
Parameters
queryMappedCommand<T>The query to execute.
Returns
- T
The single row.
Type Parameters
TThe type each row is mapped to.
Remarks
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.
The more-than-one error is thrown at the second row, before the later result sets are read, so it is never replaced by a later failure.
Exceptions
- ArgumentNullException
queryis null.- InvalidOperationException
The query returns no rows, or more than one row.
- See Also
-
SingleOrDefault()First()