2011年10月26日
摘要: 学习Linq时,经常会遇到Linq使用Group By问题,这里将介绍Linq使用Group By问题的解决方法。1.计数var q = from p in db.Products group p by p.CategoryID into g select new { g.Key, NumProducts = g.Count() }; 语句描述:Linq使用Group By和Count得到每个CategoryID中产品的数量。说明:先按CategoryID归类,取出CategoryID值和各个分类产品的数量。2.带条件计数var q = from p in db.Products group 阅读全文
posted @ 2011-10-26 23:34 苍茫大地NV 阅读(277) 评论(0) 推荐(0) 编辑