'Creating Dict<enum, List<objec>> from List<object> using LINQ C#

I have the following enums and class:

public enum SymbolTypeEnum
{
    [Description("Forex")]
    forex = 0,
    [Description("Metals")]
    metals = 1,
    [Description("Commodities")]
    commodities = 2,
    [Description("Indices")]
    indices = 3,
    [Description("Cryptocurrency")]
    cryptocurrency = 4,
    [Description("Other")]
    other = 5
}

public enum SymbolClassificationEnum
{
    [Description("None")]
    none = 0,
    [Description("Major")]
    major = 1,
    [Description("Minor")]
    minor = 2,
    [Description("Exotic")]
    exotic = 3
}
public class SymbolSettingsModel
{
    [PrimaryKeyAttribute, Unique]
    public string symbolName { get; set; }
    public SymbolTypeEnum symbolType { get; set; }
    public SymbolClassificationEnum symbolClassification { get; set; }
}

I have a List<SymbolSettingsModel> symbolSettings;

My goal is to generate a Dictionary<SymbolTypeEnum, List<SymbolDescr>> typeSymbolsSettingsData;

Where SymbolDescr is:

class SymbolDescr
{
    public string symbol { get; set; }
    public int classification { get; set; }
}

The idea is to group them by symbolType and use it as a Key for the dictionary, and generate a list of SymbolDescr. Here is my code so far:

typeSymbolsSettingsData = symbolSettings.GroupBy(p => p.symbolType)
            .ToDictionary(p => p.Key, p => p.ToList());

I am stuck at this point, do you have any ideas how I can do this ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source