SqlSet<TResult>.Single(SqlSet.OperatorStringHandler) Method
Returns the only element of the set that satisfies a specified condition, and throws an exception if more than one such element exists.
Namespace: DbExtensions
Assembly: DbExtensions.dll
Overloads
| Name | Description |
|---|---|
| Single() | The single element of the set. |
| Single(OperatorStringHandler) | Returns the only element of the set that satisfies a specified condition, and throws an exception if more than one such element exists. |
| Single(String) | Returns the only element of the set that satisfies a specified condition, and throws an exception if more than one such element exists. |
Syntax
public TResult Single(
ref OperatorStringHandler predicate
)
Parameters
predicate OperatorStringHandler
A SQL expression to test each row for a condition.
Return Value
TResult
The single element of the set that passes the test in the specified predicate.
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | No element satisfies the condition in predicate.-or-More than one element satisfies the condition in predicate.-or-The set is empty. |