Skip to main content
.NET Framework 4.6.2+

XPQueryExtensions.SingleOrDefaultAsync Method

Name Parameters Description
SingleOrDefaultAsync<T>(IQueryable<T>, Expression<Func<T, Boolean>>, CancellationToken) static query, predicate, cancellationToken

Asynchronously gets the object from a selection if only one object in the selection meets the specified requirements. If the selection is empty, returns a default value for <T>. If the selection has more than one of such elements, throws an exception.

SingleOrDefaultAsync<T>(IQueryable<T>, CancellationToken) static query, cancellationToken Asynchronously gets the only object in a selection. If the selection is empty, returns a default value for <T>. If the selection has more than one element, throws an exception.