var a = from u in Users
group u by new {u.UserName,u.Address,u.City,u.State} into abc
select new
{
Count=abc.Count(),
Name= abc.Key.UserName,
Address=abc.Key.Address,
State=abc.Key.State,
City=abc.Key.City
};
答案 0 :(得分:2)
试试这个
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
});