我有一个EmployeeInfo
个对象的列表,我想从Country
和Department
建立一个表并对Employees进行分组。我需要按国家/地区对EmployeeInfo列表进行分组,然后按部门对每个分组列表组进行分组并处理每个列表。
我尝试了很多方法,但没有让它发挥作用。
我试过这样的事情:
public class EmployeeInfoToTableDataSetTypeConverter : ITypeConverter<List<EmployeeInfo>,
List<TableDataSet>>
{
public List<TableDataSet> Convert(ResolutionContext context)
{
return
(from EmployeeInfo in ((List<EmployeeInfo>)(context.SourceValue))
group EmployeeInfo by EmployeeInfo.Country
into EmployeeInfos
select //Here I would need to "select" EmployeeInfo from EmployeeInfos
group by EmployeeInfo.Department - but it does not work like this
new TableDataSet()
答案 0 :(得分:0)
这是让你入门的东西:
var groupedList = ((List<EmployeeInfo>)(context.SourceValue)).
GroupBy(x => x.Country).
ToDictionary(x => x.Key, x => x.
GroupBy(y => y.Department));