linq——group by

多列排序&&聚合函数

var result = from i in
               (from uh in db.UserHistories
                where uh.User.UserID == UserID && uh.CRMEntityID == (int)entity
                select new { uh.ActionID, uh.ActionType, uh.ObjectID, uh.Date })
             group i by new { i.ActionID, i.ActionType, i.ObjectID } into g
             select new { g.Key.ActionID, g.Key.ActionType, g.Key.ObjectID, g.Max(uh=>uh.Date) }; 
 

  

posted @ 2017-08-10 18:36  PanPan003  阅读(521)  评论(0编辑  收藏  举报