本文介绍了可以在Linq to SQL中选择多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好, 我正在尝试在SQL中加入。我做连接但它总是返回第一个对象而不是对象集合。这是我的代码: IEnumerable< FigureModel> data =( from figure in context.Figures rarity context.Rarities on figure.RarityID等于rarity.RarityID join figureKeywords in context.FigureKeywords on figure.FigureID equals figureKeywords.FigureID join keywords in context.Keywords on figureKeywords.KeywordID equals keywords.KeywordID where figure.Name.Contains( QueryString)&&((powerMap& figure.PowerMap)== powerMap)&& (S electionsSet == null ? true :figure.SetID == SelectedSet.SetID) select new FigureModel { Cost = figure.Cost, Name = figure.Name, Rarity = rarity.Name, SetNumber = figure.SetNumber.ToUpper(), }); 图形链接到FigureKeywords表,然后链接关键字表。问题是,如果我尝试查询figureKeywords它不给我一个集合它给我一个FigureKeywords的实例? 提前谢谢, - Dom 解决方案 嗨DominicZA, 希望这可以帮到你 http://stackoverflow.com/questions/2723985/linq-join-2-listts [ ^ ] 如果您需要更多帮助,请在这里询问。 谢谢 Ganesh Hi there,I am trying to do a join in SQL. I do the join but it always returns the first object instead of a collection of objects. Here is my code:IEnumerable<FigureModel> data = (from figure in context.Figures join rarity in context.Rarities on figure.RarityID equals rarity.RarityID join figureKeywords in context.FigureKeywords on figure.FigureID equals figureKeywords.FigureID join keywords in context.Keywords on figureKeywords.KeywordID equals keywords.KeywordID where figure.Name.Contains(QueryString) && ((powerMap & figure.PowerMap) == powerMap) && (SelectedSet == null ? true : figure.SetID == SelectedSet.SetID) select new FigureModel { Cost = figure.Cost, Name = figure.Name, Rarity = rarity.Name, SetNumber = figure.SetNumber.ToUpper(), });A figure links to the FigureKeywords table which then links Keywords table. The problem is that if I try query figureKeywords it isnt giving me a collection its giving me a single instance of FigureKeywords?Thanks in advance,- Dom 解决方案 Hi DominicZA,Hope this helps youhttp://stackoverflow.com/questions/2723985/linq-join-2-listts[^]If u need any more help, just ask here.ThanksGanesh 这篇关于可以在Linq to SQL中选择多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-13 05:19