本文介绍了Linq从列表中查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个列表< int>我想查询一个数据集。我遇到的问题是它只能抓住一个。即用下一次迭代替换先前的查询。你能帮忙吗? I have a list<int> that I would like to query a dataset off of. The problem I have is that it only appears to grab one. i.e. replacing the previous query with the next iteration. Can you help? 公共 列表 < League > GetLeaguesInformation( List < int > LeagueList) {public List<League> GetLeaguesInformation(List<int> LeagueList){ LeagueInformationClassesDataContext db = new LeagueInformationClassesDataContext (); LeagueInformationClassesDataContext db = new LeagueInformationClassesDataContext(); IQueryable < 联盟 > LeagueResults = db.Leagues; IQueryable<League> LeagueResults = db.Leagues; foreach ( var xx LeagueList) {foreach (var xx in LeagueList){ LeagueResults = LeagueResults.Where(a => a.ID == xx); LeagueResults = LeagueResults.Where(a => a.ID == xx);} var 输出=( 来自 p in LeagueResults var output = (from p in LeagueResults 选择 p); select p); return output.ToList(); } return output.ToList();}推荐答案 return 这篇关于Linq从列表中查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-18 06:26