I have a List of Anonymous objects containing following fields in C# derived from a LINQ query.
{
String category
decimal Jan
decimal Feb
decimal Mar
decimal Apr
decimal May
decimal Jun
decimal Jul
decimal Aug
decimal Sep
decimal Oct
decimal Nov
decimal Dec
}
how could I create a list of Objects having one field for each value of category ( so essentially 12 objects one object for each month( jan, feb, march etc.).
ExpectedResult {
string Month,
decimal category1,
decimal category2,
decimal category3,
...
decimal categoryN
}
So result would have 12 objects of ExpectedResult. Not knowing how many categories/is a problem. Any quick suggestion would be helpful.
var Jan = { Cat1Name = 1.3, Cat2Name = 15.5, Cat3Name = 90.6, ... }? What to do if the category name is not a valid C# identifier?