[Linq问题没有解决,再发一贴,在线等]
我有三个下拉列表ddl1,ddl2,ddl3,里面的集合是相同的,购买者、销售者、生产厂家三方面
对这三部分进行分组后,如果选择购买者进行分组,就要显示出购买者的姓名和购买次数,按照购买数量降序排列,其他同理
var query = from p in list group p by new { //???//例如下拉列表中的值ddl1.SelectValue为"Purchaser",如何写成p.Purchaser,其他同理 //p.Purchaser, //p.Seller, //p.Producer } into g select new { //??? //如何列出购买者的姓名和购买数量,其他同理 //g.Key, // Count = g.Count() };private static object GetPropertyValue(object obj, string property) { System.Reflection.PropertyInfo propertyInfo = obj.GetType().GetProperty(property); return propertyInfo.GetValue(obj, null); }var result = from a in list.GroupByMany("A", "B") from b in a.SubGroups orderby b.Count descending select new { Key1 = a.Key ?? "@", //当a.Key为空时,转成@ Key2 = b.Key ?? "$", //当b.Key为空时,转成$ Count = b.Count };