在MVC中使用Linq进行分组 [英] Grouping using Linq in MVC
本文介绍了在MVC中使用Linq进行分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在mvc中显示组中的记录
How to show record in the group in mvc
推荐答案
试试此代码..
Try this code..
var results = from p in persons
group p.car by p.PersonId into g
select new { PersonID = g.Key, Cars = g.ToList() };
或包含连锁声明..
or incase of chain statement..
var results = persons.GroupBy(p => p.PersonId, p => p.car,
(key, g) => new { PersonId = key, Cars = g.ToList() });
如果这解决了你的问题类型ly up vote并将其标记为解决方案..谢谢..
If this solves your issue kindly up vote and mark this as solution.. Thanks..
http://ole.michelsen.dk/blog/grouping-data-with-linq-and-mvc.html [ ^ ]
这篇关于在MVC中使用Linq进行分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文