我有在它的数字(5,9,3)的列表。让我们把它MYLIST

我想执行

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

现在我

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);
}

我敢肯定,必须有一个更好的办法,但我不能完全换我的头周围。

有帮助吗?

解决方案

var results = from a in myEntities.thing1 where MyList.Contains(a) select a;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top