Bright Leopold

i come from the other world,i will go back after the love,the regret,the alive and the dead are over

导航

2012年12月28日

Linq 求和,求平均值,求最大,求最小,分组,计数.....

摘要: 1.简单形式:var q =from p in db.Productsgroup p by p.CategoryID into gselect g;语句描述:使用Group By按CategoryID划分产品。说明:from p in db.Products 表示从表中将产品对象取出来。group p by p.CategoryID into g表示对p按CategoryID字段归类。其结果命名为g,一旦重新命名,p的作用域就结束了,所以,最后select时,只能select g。当然,也不必重新命名可以这样写:var q =from p in db.Productsgroup p by p. 阅读全文

posted @ 2012-12-28 20:33 Bright Leopold 阅读(2402) 评论(0) 推荐(1)