Queryable.MinBy 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.
Overloads
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>) |
Returns the minimum value in a generic IQueryable<T> according to a specified key selector function. |
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>) | |
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TSource>) |
Obsolete.
Returns the minimum value in a generic IQueryable<T> according to a specified key selector function. |
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>)
- Source:
- Queryable.cs
- Source:
- Queryable.cs
- Source:
- Queryable.cs
- Source:
- Queryable.cs
Returns the minimum value in a generic IQueryable<T> according to a specified key selector function.
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static TSource MinBy(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector);
public static TSource? MinBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);
static member MinBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> -> 'Source
<Extension()>
Public Function MinBy(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey))) As TSource
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of key to compare elements by.
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.
Returns
The value with the minimum key in the sequence.
Exceptions
source
is null
.
No key extracted from source
implements the IComparable or IComparable<T> interface.
Applies to
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TKey>)
- Source:
- Queryable.cs
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static TSource MinBy(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector, System::Collections::Generic::IComparer<TKey> ^ comparer);
public static TSource? MinBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? comparer);
static member MinBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Key> -> 'Source
<Extension()>
Public Function MinBy(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), comparer As IComparer(Of TKey)) As TSource
Type Parameters
- TSource
- TKey
Parameters
- source
- IQueryable<TSource>
- keySelector
- Expression<Func<TSource,TKey>>
- comparer
- IComparer<TKey>
Returns
Applies to
MinBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IComparer<TSource>)
- Source:
- Queryable.cs
- Source:
- Queryable.cs
- Source:
- Queryable.cs
- Source:
- Queryable.cs
Caution
The Queryable MinBy and MaxBy taking an IComparer<TSource> are obsolete. Use the new ones that take an IComparer<TKey>.
Returns the minimum value in a generic IQueryable<T> according to a specified key selector function.
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static TSource MinBy(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector, System::Collections::Generic::IComparer<TSource> ^ comparer);
[System.Obsolete("The Queryable MinBy and MaxBy taking an IComparer<TSource> are obsolete. Use the new ones that take an IComparer<TKey>.", DiagnosticId="SYSLIB0061", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static TSource? MinBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TSource>? comparer);
public static TSource? MinBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IComparer<TSource>? comparer);
[<System.Obsolete("The Queryable MinBy and MaxBy taking an IComparer<TSource> are obsolete. Use the new ones that take an IComparer<TKey>.", DiagnosticId="SYSLIB0061", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member MinBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Source> -> 'Source
static member MinBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IComparer<'Source> -> 'Source
<Extension()>
Public Function MinBy(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), comparer As IComparer(Of TSource)) As TSource
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of key to compare elements by.
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.
- comparer
- IComparer<TSource>
The IComparer<T> to compare keys.
Returns
The value with the minimum key in the sequence.
- Attributes
Exceptions
source
is null
.
No key extracted from source
implements the IComparable or IComparable<T> interface.