为什么我会收到以下编译错误?
int[] threadIDs = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17 };
CSDataContext db = new CSDataContext();
var posts = from p in db.cs_Posts, t in threadIDs
where p.ThreadID == t
select p.ThreadID;
答案 0 :(得分:6)
你想做什么?选择列表中包含线程ID的所有帖子?
然后这样的事情会起作用
int[] threadIDs = {4,5,6,7,8,9,10,11,12,13,14,15,16,17};
CSDataContext db = new CSDataContext();
var posts = from p in db.cs_Posts
where threadIds.Contains(p.ThreadID)
select p.ThreadID;
答案 1 :(得分:2)
你试过吗
var posts = from p in db.cs_Posts
from t in threadIDs
where p.ThreadID == t
select p.ThreadID;
省略逗号并添加另一个'from'