下面的linq查询显示了我的所有结果集,而不是使用where子句premalink.PremalinkID == id ???
过滤它 lstpremalink = dalpremalink.GetUserNewsFeed(UserID);
var premalinkid = (from p in lstpremalink select p.PremalinkID).Distinct();
foreach (Int64 id in premalinkid)
{
lstprema = (from premalinktags in lstpremalink
where premalinktags.PremalinkID == id
select premalinktags).ToList();
}
lstprema显示
下面的所有结果集
答案 0 :(得分:3)
lstprema = (from premalinktags in lstpremalink
where premalink.PremalinkID == id select premalinktags).ToList();
您按premalinktags
进行迭代,但您的where
子句不包含该变量!不应该是premalinktags.PremalinkID == id
吗?
答案 1 :(得分:0)
lstpremalink = dalpremalink.GetUserNewsFeed(UserID);
var premalinkid = (from p in lstpremalink
where p.PremalinkID == lstpremaLink.ID
select p).Distinct();
您必须使用where条件