我试图在代码中找出 ToLookup 方法的功能。它以某种方式使用分组来返回一个列表。有人可以告诉我这是如何工作的,或者只是引导我朝着正确的方向前进:
.ToLookup(
c => new
{
c.CoverageType.Code,
c.CoverageType.Mnemonic,
c.CoverageType.Description,
c.CoverageType.CoverageLevel,
c.CoverageType.CoveragePosition
})
.Select(
t => new CoverageOption
{
CoverageType =
new CoverageType
{
Code = t.Key.Code,
Mnemonic = t.Key.Mnemonic,
Description = t.Key.Description,
CoverageLevel = t.Key.CoverageLevel,
CoveragePosition = t.Key.CoveragePosition
},
Limits =
(from Coverage c in t select c.Limit).GroupBy(l => l.Code)
.Select(gr => gr.First()),
Deductibles =
(from Coverage c in t select c.Deductible).GroupBy(d => d.Code)
.Select(gr => gr.First())
})
.OrderBy(t => t.CoverageType.CoveragePosition);