Tiger Bonzo
Tiger Bonzo

Reputation: 51

Select dictionary from dictionares?

I have problem with select dicionary from dictionares, my structure Dictionary<long, Dictionary<long, object>> i try Select(x => x.Value) and SelectMany(x => x.Value) but result is IEnuerable<Dictionary<long, object>> do you have any ideas, how can i select this dictionary?

Upvotes: 0

Views: 101

Answers (2)

Krishna Varma
Krishna Varma

Reputation: 4260

Select and SelectMany will result in IEnumerable

try with SelectMany and then convert to desired Dictionary

var result = dd.SelectMany(x => x.Value)
               .ToDictionary(x => x.Key, y => y.Value);

Upvotes: 0

hvassup
hvassup

Reputation: 159

Select returns an IEnumerable, so you should either do .FirstOrDefault() on the result, or use a method like TryGetValue

Upvotes: 1

Related Questions