var items = List<实体>;
var models = items.GroupBy(r => r.分类字段).ToDictionary(d => d.Key, d => d.ToList());
分类字段值相同的数据都会归为一类。主键为key
具体取值方法
foreach(var model in models)
{
var key = model.key;
var value = model.value;
}
时间: 2024-09-30 05:47:24
var items = List<实体>;
var models = items.GroupBy(r => r.分类字段).ToDictionary(d => d.Key, d => d.ToList());
分类字段值相同的数据都会归为一类。主键为key
具体取值方法
foreach(var model in models)
{
var key = model.key;
var value = model.value;
}