I'd like to compute a merged dictionary based on an input of List<IDictionary<string,object>>
.
Typically this would be the combination of the explicit merged_dataset
copy followed by a foreach
:
var merged_dataset = my_datasets.SelectMany(dict => dict)
.ToLookup(pair => pair.Key, pair => pair.Value)
.ToDictionary(group => group.Key, group => group.ToList());
foreach (var item in merged_dataset)
[...logic based on item.Value.Distinct()...]
Is there a way to do the above "on-the-fly", without an explicit call to ToDictionary
which constructs merged_dataset
and somewhat like a Enumerable.Zip
with two datasets, but with a List
of N-datasets as input ?
In the end I would end up with:
var iterator = my_datasets.SelectMany(dict => dict)
.GroupBy(dict => dict.Key)[...missing ToList...]
foreach ((string key, List<object> values) in iterator)
References: