I have a mapping table as follows:
Id ReferenceId ReferenceType LinkId
To get a set of combinations, I could execute each request separately:
var pairs = new List<Pair>
{
Pair.Create(1000, "Car"),
Pair.Create(2000, "Truck"),
};
var maps = new List<Mapping>();
foreach (var pair in pairs)
{
maps.AddRange(context.Mappings.Where(x => x.ReferenceId = pair.Id && x.ReferenceType == pair.Type).ToList());
}
However, I want to combine them into one operator to reduce my db hits. Is there any form of the Contains operator that can work with pairs of objects? Or can I add an OR clause in an IQueryable in a loop? Any other solutions?
source
share