Skip to content

TQueryLinqExtensions_SingleOrDefault_6sfPbuxwSRA0hp3rDwdmQg

Jacob Spitzer edited this page Aug 28, 2022 · 2 revisions

TQueryLinqExtensions.SingleOrDefault<Table>(DbEcExtended<Table>, Expression<Func<Table,bool>>) Method

Returning the only record of the TQuery recordset that satisfies a specified condition, or NULL if no such record is found, and throws an exception if there is not exactly one record that satisfies the predicate function.

public static Table SingleOrDefault<Table>(this DbEasyConnect.DbEcExtended<Table> tQuery, System.Linq.Expressions.Expression<System.Func<Table,bool>> predicate);

Type parameters

Table
The type of the records of table class. need to be a class with the [Table("")] attribute.

Parameters

tQuery DbEasyConnect.DbEcExtended<Table>
An DbEcExtended<T> to apply the predicate to.

predicate System.Linq.Expressions.Expression<System.Func<Table,System.Boolean>>
A function to test each record for a condition.

Returns

Table
NULL if TQuery recordset is empty or if no record passes the test specified by predicate; otherwise, the single record in TQuery recordset that passes the test specified by predicate.

Clone this wiki locally