日期:2014-05-20 浏览次数:20821 次
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 };