I have a set of data which I'm retrieving through a Service Reference in C#. I'm trying to output that data into a CSV to summarize it for a report. Basically my final report should have 3 columns: Month | Store | Category | Cost
, and so in my C# I'm retrieving the data for various sales lines from the data source and getting the Month, Store, Category and Cost for each line. I'm trying to use a data structure to sum up the cost for every line that has the same Month, Store and Category, and my intuition is to use a Dictionary:
var monthSales = new Dictionary<int, Dictionary<String, Dictionary<String, Decimal>>>();
So I get a line from my data source, get it's month, check if the month already exists in the dictionary, and if it doesn't, create a new entry for that month, and then in the next dictionary down I do the same for the Store, and then in the next dictionary down I do the same for the Category, and then I add the cost to the existing cost if there was an existing cost.
I just feel like I'm doing this the wrong way. Feels very long-winded.