Click or drag to resize

QueryableExtensionMethods.FirstOrDefaultAsync<TSource> Method (IQueryable<TSource>, Expression<Func<TSource, Boolean>>, TSource, CancellationToken)

Async variant of Queryable.FirstOrDefault

Namespace:  SD.LLBLGen.Pro.LinqSupportClasses
Assembly:  SD.LLBLGen.Pro.ORMSupportClasses (in SD.LLBLGen.Pro.ORMSupportClasses.dll) Version: 5.10.0.0 (5.10.0)
Syntax
public static Task<TSource> FirstOrDefaultAsync<TSource>(
	this IQueryable<TSource> source,
	Expression<Func<TSource, bool>> predicate,
	TSource defaultValue,
	CancellationToken cancellationToken
)

Parameters

source
Type: System.Linq.IQueryable<TSource>
The source.
predicate
Type: System.Linq.Expressions.Expression<Func<TSource, Boolean>>
The predicate.
defaultValue
Type: TSource
The default value to return if the sequence is empty
cancellationToken
Type: System.Threading.CancellationToken
The cancellation token.

Type Parameters

TSource
The type of the source.

Return Value

Type: Task<TSource>

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable<TSource>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also