Queryable.DistinctBy 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
DistinctBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>) |
Returns distinct elements from a sequence according to a specified key selector function. |
DistinctBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IEqualityComparer<TKey>) |
Returns distinct elements from a sequence according to a specified key selector function. |
DistinctBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>)
Returns distinct elements from a sequence according to a specified key selector function.
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static System::Linq::IQueryable<TSource> ^ DistinctBy(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector);
public static System.Linq.IQueryable<TSource> DistinctBy<TSource,TKey> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);
static member DistinctBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function DistinctBy(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey))) As IQueryable(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of key to distinguish elements by.
Parameters
- source
- IQueryable<TSource>
The sequence to remove duplicate elements from.
- keySelector
- Expression<Func<TSource,TKey>>
A function to extract the key for each element.
Returns
An IQueryable<T> that contains distinct elements from the source sequence.
Exceptions
source
is null
.
Applies to
DistinctBy<TSource,TKey>(IQueryable<TSource>, Expression<Func<TSource,TKey>>, IEqualityComparer<TKey>)
Returns distinct elements from a sequence according to a specified key selector function.
public:
generic <typename TSource, typename TKey>
[System::Runtime::CompilerServices::Extension]
static System::Linq::IQueryable<TSource> ^ DistinctBy(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, TKey> ^> ^ keySelector, System::Collections::Generic::IEqualityComparer<TKey> ^ comparer);
public static System.Linq.IQueryable<TSource> DistinctBy<TSource,TKey> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer);
static member DistinctBy : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, 'Key>> * System.Collections.Generic.IEqualityComparer<'Key> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function DistinctBy(Of TSource, TKey) (source As IQueryable(Of TSource), keySelector As Expression(Of Func(Of TSource, TKey)), comparer As IEqualityComparer(Of TKey)) As IQueryable(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
- TKey
The type of key to distinguish elements by.
Parameters
- source
- IQueryable<TSource>
The sequence to remove duplicate elements from.
- keySelector
- Expression<Func<TSource,TKey>>
A function to extract the key for each element.
- comparer
- IEqualityComparer<TKey>
An IEqualityComparer<T> to compare keys.
Returns
An IQueryable<T> that contains distinct elements from the source sequence.
Exceptions
source
is null
.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback을 참조하세요.
출시 예정: 2024년 내내 콘텐츠 피드백 메커니즘인 GitHub 문제를 단계적으로 폐지하고 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은다음에 대한 사용자 의견 제출 및 보기