Back to Devexpress

XPQueryExtensions.SingleOrDefaultAsync<T>(IQueryable<T>, CancellationToken) Method

xpo-devexpress-dot-xpo-dot-xpqueryextensions-dot-singleordefaultasync-1-x28-system-dot-linq-dot-iqueryable-0-system-dot-threading-dot-cancellationtoken-x29.md

latest2.4 KB
Original Source

XPQueryExtensions.SingleOrDefaultAsync<T>(IQueryable<T>, CancellationToken) Method

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.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public static Task<T> SingleOrDefaultAsync<T>(
    this IQueryable<T> query,
    CancellationToken cancellationToken = default(CancellationToken)
)
vb
<ExtensionAttribute>
Public Shared Function SingleOrDefaultAsync(Of T)(
    query As IQueryable(Of T),
    cancellationToken As CancellationToken = Nothing
) As Task(Of T)

Parameters

NameTypeDescription
queryIQueryable<T>

An XPQuery<T> that specifies a selection of persistent objects.

|

Optional Parameters

NameTypeDefaultDescription
cancellationTokenCancellationTokennull

A CancellationToken object that delivers a cancellation notice to the running operation.

|

Type Parameters

Name
T

Returns

TypeDescription
Task<T>

A Task that returns the only object in a selection.

|

See Also

XPQueryExtensions Class

XPQueryExtensions Members

DevExpress.Xpo Namespace