将键/列表添加到字典中

时间:2015-11-24 07:19:06

标签: c# dictionary

如何将以下查询转换为字典Dictionary<key, List<StudentSummary>以用于以下LINQ查询:

在字典中,Key将被视为first group by Key,即x.test.aList<StudentSummary>将在linq查询中进行全部第二次选择。

private void get(baseQuery) {
    List<StudentSummary> summary = baseQuery
    .GroupBy(x =>x.test.a)
    .Select(x=>new StudentSummary {
        Name = x.key.
        StudentDetails = baseQuery
        .GroupBy(y=>y.test1.b)
        .OrderBy(y => y.key)
        .Select(y => new StudentDetails {
            studentDetailsProp1 = 10;       
            studentDetailsProp2 = 10;       
        }).ToList(),        
        TotalMarks =100;        
    }).ToList();    
}

0 个答案:

没有答案