I have a table with a composite key, for example:
modelBuilder.Entity<MyEntity>().HasKey(e=> new { e.Part1, e.Part2 });
I also have a list of keys in memory for which I want to load objects, for example:
var keys = new [] { new { Part1= 1, Part2 = 2}, new { Part1= 3, Part2 = 4} }
How can I execute one request to load objects in an array of keys?
I tried obvious things like ctx.MyEntities.Where(e => keys.Any(k => k.Part1 == e.Part1 && k.Part2 == e.Part2))
This answer suggests that this is not possible, but certainly not so.
source
share