Reading database table into a .NET object of different structure -


i have inflation rates stored in database following structure:

database schema , sample data

when reading above data, need initialize business objects different structure dynamically , fill them database data.

if database above, need create 2 objects: "uk inflation forecast" , "germany inflation forecast". in case, both objects have 6 properties: countryname (as string) , 5 inflation values (as double).

business objects

how can create object classes without knowing number of properties needed , how fill these data?

i create class of following structur:

public class inflationclass {     public inflationclass()     {         inflationvalues = new dictionary<int, double>();     }      public string country { get; set; }     public dictionary<int, double> inflationvalues { get; private set; } } 

and load data so

int sampleyear = 2016; double samplevalue = 123456789.01;  var inflation = new inflationclass();  if(!inflation.inflationvalues.containskey(sampleyear )) {     inflation.inflationvalues.add(sampleyear , samplevalue); } 

i've used c# can converted vb.net if prefer.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -