Support Contains with a parameterized collection of tuples (e.g. for filtering on composite keys)

Open
#11,799 13 comments 31 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
backend, databases

Research direction

Start with the LINQ query in the issue body and investigate how EF Core handles Contains over a collection of tuples for composite keys. Reproduce the query against a database and define done as translating the tuple collection to SQL rather than evaluating it client-side.

Written by the indexing model from the issue text.

Description

area-query

Currently, the only supported method for using a "Contains" statement on a composite key in EFCore 2.1 is to use a tuple and it is evaluated client-side. EF Core should be able to translate it to SQL.

For example:

return DbContext.PurchaseOrders
                .Where(po => myKeys.Contains(new Tuple<string, int>(po.KeyPart1, po.KeyPart2)))
                .ToList();

Could this be added to the backlog?

Dominant language
C#
Stars
14.8k
Forks
3.4k
Avg merge
2d 5h
Merged PRs (30d)
134

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/efcore

All issues in dotnet/efcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.