开发者

How do i convert following query with lambda operator

开发者 https://www.devze.com 2023-03-31 22:12 出处:网络
var a = from u in Users group u by new {u.UserName,u.Address,u.City,u.State} into abc select ne开发者_Go百科w
var a = from u in Users
                group u by new {u.UserName,u.Address,u.City,u.State} into abc
                select ne开发者_Go百科w
                {
                    Count=abc.Count(),
                    Name= abc.Key.UserName,
                    Address=abc.Key.Address,
                    State=abc.Key.State,
                    City=abc.Key.City   
                };


Try this

var a = users.GroupBy(u => new {u.Username, u.Address, u.City, u.State})
        .Select(abc => new
                          {
                               Count = abc.Count(),
                               Name = abc.Key.Username,
                               Address = abc.Key.Address,
                               State = abc.Key.State,
                               City = abc.Key.City
                           });
0

精彩评论

暂无评论...
验证码 换一张
取 消