我需要以下结果才能帮助我?
City || State || Zip
---------------------------------------
Mayo || FL || 234234
Mayo || SC || 323455
Mayo || MD || 665777
Select Distinct(City), State, Max(Zip) As Zip from Zipcode Group By City,State Order By City
这样的行可以在这里输入代码
Mayo MD 665777
Mayo MD 234566
Mayo MD 667568
但我需要跳过并使用它的最大拉链。
此查询正常但我想将其转换为linq。
答案 0 :(得分:1)
您可以这样做: -
var output= countries.GroupBy(c => new { c.State, c.City })
.Select(a => new
{
City = a.Key.City,
State = a.Key.State,
Zip = a.Max(z => z.Zip)
}).OrderBy(m => m.City);