List<System.Linq.Expressions.Expression<Func<MyType, bool>>> lstPredicates = new List<System.Linq.Expressions.Expression<Func<MyType, bool>>>();
foreach (MyType myAccount in lstMyType)
{
System.Linq.Expressions.Expression<Func<MyType, bool>> predicate =
t => t.Account == myAccount.Account && t.Branch == myAccount.Branch;
lstPredicates.Add(predicate);
}
lstTransactions = Context.MyTrans
.Where(lstPredicates)
.ToList();
I am trying to run the lookup in MyTrans
table only once, so I am building up a list of predicates. I want to retrieve transactions in a list where any of the account and branch combinations exists in transactions.
i.e. I am trying to produce a predicate like
predicate = t =>
(t.Account == 123 && t.Branch == London)
|| (t.Account == 433 && t.Branch == Manchester)
||...