因为目前我无法检索
的问题 public IQueryable<Issue> commodityMatch_GetData(){
string userName = HttpContext.Current.User.Identity.Name;
Context db = new Context();
IQueryable<Issue> query = db.Issues;
//currently is filter by commodity and product line
//looking on how to only filter by commodity
var x = from r in db.Records
where r.Username1 == userName
select r.CommodityID;
System.Diagnostics.Debug.WriteLine("Im fucking here");
foreach(int s in x)
{
//s got 17 and 18
System.Diagnostics.Debug.WriteLine(s);
query = query.Where(p => p.CommodityID == s);
//how to run mutiple time and return multiple times?
//return mean end
}
return query;
}
例如在var x中我有2个int,即17和18,但在上面的代码中,我无法检索商品= 17和18的问题。
foreach(int s in x)
{
//s got 17 and 18
System.Diagnostics.Debug.WriteLine(s);
query = query.Where(p => p.CommodityID == s);
return query;
}
如果在这里返回查询,它只显示商品17的问题,然后它没有显示商品18的问题。
答案 0 :(得分:0)
尝试将问题加入到单个LINQ查询的记录中:
var x = from r in db.Records
join i in db.Issues
on r.CommodityID == iCommodityID
where r.Username1 == userName
select i;
return x;