user2420472
user2420472

Reputation: 1177

C# LINQ converting a query to dictionary

A C# converting a query to dictionary:

public class myClass
{
    public int my_id;
    public Dictionary<string, Dictionary<string, string[]>> myDict;
}

Dictionary<string, myClass> dataDict;

Dictionary<int, Dictionary<string, myClass>> query = (from happen in dataDict 
                     group happen by happen.Value.my_id into g 
                     select g).ToDictionary( ?? );

I do not know what I should put in ( ?? ).

Any help would be appreciated.

Upvotes: 0

Views: 81

Answers (1)

Selman Gen&#231;
Selman Gen&#231;

Reputation: 101732

Try this:

var query = (from happen in dataDict
            group happen by happen.Value.my_id into g select g)
           .ToDictionary(g => g.Key, g => g.ToDictionary(x => x.Key, x => x.Value));

Upvotes: 1

Related Questions