I have a list of { string Key, IEnumerable<string> Values }
items and want to transform it into a list of { string Key, string Value }
items, such that the new list contains n
items for each Key
.
I want to use LINQ and had the idea to use SelectMany
:
list.SelectMany(item => item.Values)
However, as you can see, I lose the Key
with that transformation. What's the trick? I guess it should be easy and I am just missing the forest for the trees...