Waleed Al-akrabawe
Waleed Al-akrabawe

Reputation: 1

How to use contain to filter multiple values

I have two table item table and transaction table. I need to use Contain to filter for two values.

var list1= table.select(c=> new {c.ID , c.ItemID}).tolist();

var list2 = tableItem.where(x=> list1.contains(x.id ,x.itemID ));

Upvotes: 0

Views: 223

Answers (1)

Airn5475
Airn5475

Reputation: 2492

This should work for you, may require a few tweaks since you're syntax looks a little rough.
Note the Any LINQ function I used. More details here

var list1 = table.Select(c => new { c.ID, c.ItemID }).ToList();

var list2 = tableITem.Where(x => list1.Any(a => a.ID == x.id && a.ItemID == x.itemID)).ToList();

Upvotes: 1

Related Questions