将查询转换为字典的C#:
public class myClass
{
public int my_id;
public Dictionary<string, Dictionary<string, string[]>> myDict;
}
Dictionary<string, myClass> dataDict;
Dictionary<int, Dictionary<string, myClass>> query = (from happen in dataDict
group happen by happen.Value.my_id into g
select g).ToDictionary( ?? );
我不知道应该放什么(??)。
任何帮助将不胜感激。
答案 0 :(得分:1)
试试这个:
var query = (from happen in dataDict
group happen by happen.Value.my_id into g select g)
.ToDictionary(g => g.Key, g => g.ToDictionary(x => x.Key, x => x.Value));