I have an entity (Entity Framework 6) which maps to a table which has 100 columns named col_1, col_2 etc. The table is an existing legacy table which is used to interface to another system, so it's very generic and will never change.
So the entity has 100 properties which map to those columns.
public class DataEntity{
public string Column1{get;set;}
...
}
I then have data like this:
var columnNumber = 1;
var data = "The data";
How can I set col_1 to "The Data" without a long case statement?
var dataEntity = new DataEntity();
This is what I don't want to do:
switch(columnNumber)
{
case 1:
dataEntity.Column1 = data;
break;
}
Note that it is not possible to change the structure of the entity.