Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make a contains query of composite key #1635

Open
hoxcape opened this issue Apr 19, 2022 · 4 comments
Open

how to make a contains query of composite key #1635

hoxcape opened this issue Apr 19, 2022 · 4 comments
Assignees

Comments

@hoxcape
Copy link

hoxcape commented Apr 19, 2022

The issue

In mysql,I can make a query like:

select * from `Table` where (Id,Name) in ((1,"test"),...);

How can I make a query like above in ef core using pomelo driver?

@mguinness
Copy link
Collaborator

mguinness commented Apr 19, 2022

Row Constructor isn't supported in EF Core, see Expand tuples to multiple columns for more details.

@hoxcape
Copy link
Author

hoxcape commented Apr 20, 2022

@mguinness how about this syntax?translate Contains method of object array

var entities= ctx.Entities.Where(e => new[]
{
    new { Id = 1, Type = 1 },
    new { Id = 2, Type = 1 }
}.Contains(new { b.Id, b.Type})).ToList();

@mguinness
Copy link
Collaborator

That is the syntax that is being proposed, but it is still in planning stage. See similar issue npgsql/efcore.pg#898 for PostgreSQL.

@lauxjpn
Copy link
Collaborator

lauxjpn commented May 13, 2022

@hoxcape You should be able to build something semantically equivalent by manually crafting the expression tree of the conditions that you want and use it as the Where() parameter.

If you need some sample code, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants