Table of Contents

SingleOrDefaultAsync Method

Definition

Namespace
Savvyio
Assemblies
Savvyio.Core.dll
Source
src/Savvyio.Core/TaskExtensions.cs

SingleOrDefaultAsync<T>(Task<IEnumerable<T>>)

Asynchronously returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.

public static Task<T> SingleOrDefaultAsync<T>(this Task<IEnumerable<T>> source)

Parameters

source Task<IEnumerable<T>>

The Task<TResult> to return the single element of.

Returns

Task<T>

A task that represents the asynchronous operation. The task result contains the single element of the input sequence, or default (TSource) if the sequence contains no elements.

Type Parameters

T

The type of the elements of source.