How do I use Linq ToDictionary to return a dictionary with multiple values in the dictionary items?

You could first group all your result by name and then call to dictionnary with the group key as key I don't know how to code it in VB but what it would look like in C Dictionary> dict = orders . GroupBy(x => x. Name) .

ToDictionary(gr => gr. Key,gr=>gr.ToList() ).

You could first group all your result by name and then call to dictionnary with the group key as key I don't know how to code it in VB but what it would look like in C# Dictionary> dict = orders . GroupBy(x => x. Name) .

ToDictionary(gr => gr. Key,gr=>gr.ToList() ).

Dim f = d. GroupBy(Function(x) x. PoolName).

ToDictionary(Function(t) t. Key, Function(g) g.ToList()) - I'll give it a go! – digiguru Jan 26 '10 at 21:28 This worked like a dream, thanks – digiguru Jan 26 '10 at 23:12.

Instead of ToDictionary, you want ToLookup. A lookup will store a list of values for each key, so the key is no longer required to be unique. The lookup returned from this method is immutable though.

The idea is to have multiple items for each key, so the intention is to have it as unique. Is a Lookup Enumerable? – digiguru Jan 26 '10 at 23:10 Yes, it as enumeration over groupsas mentioned in the documentation: msdn.microsoft.Com/en-us/library/bb460184.

Aspx It does exactly what the accepted solution does, but is a built in function: orders. ToLookup(x => x.Name, x => x); – Chris Jan 26 '10 at 23:51.

Dictionary(Of String, Generic. Name = "Marble", . Name = "Marble", .

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions