I have a query that returns 3 columns of data.
Country | Religion | Population
--------------------------------
US | Christianity | 80000000
US | Islam | 1000000
US | Judaism | 5000000
China | Buddhism | 100000000
China | Christianity | 2345737
and so on.
I need to show this data by country. The JSON object will look like
[ { "Country" : "US",
{
"Christianity" : 80000000,
"Islam": 1000000,
"Judaism": 5000000
}
},
{ "Country" : "China",
{
"Buddhism " : 100000000,
"Christianity ": 2345737
}
}
]
What's the best way to do this? Get the data into a datatable and use LINQ to query it (if yes then how?)
Or maybe create a Dictionary>. But I am confused as to how to populate the data.
Maybe create a class with Country, Dictionary and return an array of this class.
Thanks.