Queryable.IntersectBy Method

Definition

Overloads

IntersectBy<TSource,TKey>(IQueryable<TSource>, IEnumerable<TKey>, Expression<Func<TSource,TKey>>, IEqualityComparer<TKey>)

Produces the set intersection of two sequences according to a specified key selector function.

IntersectBy<TSource,TKey>(IQueryable<TSource>, IEnumerable<TKey>, Expression<Func<TSource,TKey>>)

Produces the set intersection of two sequences according to a specified key selector function.

IntersectBy<TSource,TKey>(IQueryable<TSource>, IEnumerable<TKey>, Expression<Func<TSource,TKey>>, IEqualityComparer<TKey>)

Source:
Queryable.cs
Source:
Queryable.cs
Source:
Queryable.cs

Produces the set intersection of two sequences according to a specified key selector function.

C#
public static System.Linq.IQueryable<TSource> IntersectBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TKey> source2, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer);

Type Parameters

TSource

The type of the elements of the input sequences.

TKey

The type of key to identify elements by.

Parameters

source1
IQueryable<TSource>

An IQueryable<T> whose distinct elements that also appear in source2 will be returned.

source2
IEnumerable<TKey>

An IEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

keySelector
Expression<Func<TSource,TKey>>

A function to extract the key for each element.

comparer
IEqualityComparer<TKey>

An IEqualityComparer<T> to compare keys.

Returns

IQueryable<TSource>

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

source1 or source2 is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10

IntersectBy<TSource,TKey>(IQueryable<TSource>, IEnumerable<TKey>, Expression<Func<TSource,TKey>>)

Source:
Queryable.cs
Source:
Queryable.cs
Source:
Queryable.cs

Produces the set intersection of two sequences according to a specified key selector function.

C#
public static System.Linq.IQueryable<TSource> IntersectBy<TSource,TKey>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TKey> source2, System.Linq.Expressions.Expression<Func<TSource,TKey>> keySelector);

Type Parameters

TSource

The type of the elements of the input sequences.

TKey

The type of key to identify elements by.

Parameters

source1
IQueryable<TSource>

An IQueryable<T> whose distinct elements that also appear in source2 will be returned.

source2
IEnumerable<TKey>

An IEnumerable<T> whose distinct elements that also appear in the first sequence will be returned.

keySelector
Expression<Func<TSource,TKey>>

A function to extract the key for each element.

Returns

IQueryable<TSource>

A sequence that contains the elements that form the set intersection of two sequences.

Exceptions

source1 or source2 is null.

Applies to

.NET 10 and other versions
Product Versions
.NET 6, 7, 8, 9, 10