You can't assign Keys
and Values
to Dictionary<>
directly. But you can project data
to proper Dictionary
of Dictionaries
using LINQ:
var result = data.GroupBy(i => i.Field, (k, v) => new
{
Key = k,
Values = v.ToDictionary(x => x.Key, x => x.Value)
})
.ToDictionary(x => x.Key, x => x.Values);