人本善良

导航

linq group by

var linqResult = from c in Result.AsEnumerable()
group c by new
{

a = c.site_address_apartment,
b = c.deli_dt

} into s
select new CommunityAnalysisVO
{
deli_dt=s.Select(p=>p.deli_dt).First(),
site_address_apartment=s.Select(p=>p.site_address_apartment).First(),
deli_per=s.Sum(p=>p.deli_per),
fist_deli=s.Sum(p=>p.fist_deli),
deli_weight=s.Sum(p=>p.deli_weight),
deli_amount=s.Sum(p=>p.deli_amount),

};

 

 

Result.GroupBy(a => new { a.deli_dt, a.deli_per }).Select(b=>new CommunityAnalysisVO{
deli_dt=b.Select(ee=>ee.deli_dt).First(),
deli_per=b.Sum(ee=>ee.deli_per)

}
);

posted on 2019-02-25 17:10  简简单单2018  阅读(358)  评论(0编辑  收藏  举报