1
LINQ를 사용하여이 목록 결과를 그룹화하려면 어떻게해야합니까? firstThree? 내 그룹 방법이 작동하지 않습니다.LINQ - GROUP BY IEnumerable
var findOtherZipCodes = (from z in zipCodes
from results in zipFirstThree
where (results.region.ToUpper() == z.City
&& results.state == z.State)
select new ZipCodeFirstThree
{
region = z.City,
state = z.State,
firstThree = z.ZipCode1.ToString().Substring(0, 3),
zipCode = z.ZipCode1.ToString()
}).ToList();
findOtherZipCodes.GroupBy(x => x.firstThree).ToList();
foreach (var item in findOtherZipCodes) {
Console.WriteLine(item.region + " " + item.firstThree + " " + item.zipCode);
Thread.Sleep(500);
}
모두를 전혀 달성되지 않는 코드에서 ToList''에. 이 쿼리를 수행하기 위해이 메서드를 전혀 사용할 필요가 없습니다. – Servy