EntityFrameworkQueryableExtensions.MinByAsync<TSource,TKey> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Asynchronously returns the minimum value in a generic IQueryable<T> according to a specified key selector function.
public static System.Threading.Tasks.Task<TSource> MinByAsync<TSource,TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Threading.CancellationToken cancellationToken = default);
static member MinByAsync : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Source>
<Extension()>
Public Function MinByAsync(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), Optional cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
- TSource
The type of the elements of source.
- TKey
The type of the value returned by the function represented by keySelector.
Parameters
- source
- IQueryable<TSource>
A sequence of values to determine the minimum value of.
- keySelector
- Expression<Func<TSource,TKey>>
A function to extract the key for each element.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task contains the value with the minimum key in the sequence.
Exceptions
source or keySelector is null.
source contains no elements.
If the CancellationToken is canceled.
Remarks
Multiple active operations on the same context instance are not supported. Use await to ensure that any asynchronous operations have completed before calling another method on this context. See Avoiding DbContext threading issues for more information and examples.
See Querying data with EF Core for more information and examples.