开发者

Implementing 'belongs' with LINQ queries

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.


var results = from a in myEntities.thing1 where MyList.Contains(a) select a;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜