Question

I have a List with the numbers (5,9,3) in it. Let's call it MyList

I would like to perform

var results = from a in myEntities.thing1 where a.ID belongsto MyList select a;

right now I do

List<T> t = new List<T>(); //I actually define T to a strong type

foreach (int i in MyList)
{
t.add(from a in myEntities.thing1 where a.ID==i select a);
}

I'm sure there must be a better way, but I can't quite wrap my head around it.

Was it helpful?

Solution

var results = from a in myEntities.thing1 where MyList.Contains(a) select a;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top