I have a problem with writing a C# linq query for retrieving data from the database, based on multiple columns of a filter list.
The list of items contains multiple columns (For example A and B) and is dynamic. My first idea was to write an any statement in an where statement, but this is not allowed in EF.
var result = _repository.Where(x => items.Any(y => x.A == y.A && x.B == y.B));
I also tried the filter first only on A, retrieve all data and filter on B, but that did not perform well.
var ListA = items.Select(x => x.A).ToList();
var result = _repository.Get(x => ListA.Contains(x.A));
An other way would be to create some c# code to generate something like this:
SELECT A,B,C,D
FROM Items
WHERE
(A = 1 AND b = 1) OR
(A = 7 AND b = 2) OR
(A = 4 AND b = 3)
But there is no decent way to do this.
Has anyone an idea how to fix this issue?