It looks like you want to do this:
MyObj x = new MyObj();
x.SomeProperty = 10;
You have a table created for this, but you do not want to continue changing this table when adding
x.AnotherProperty = "Some String";
You need to normalize the table data as follows:
-> BaseTable
RecordId, Col1, Col2, Col3
-> BaseTableProperty
PropertyId, Name
-> BaseTableValue
ValueId, RecordId, PropertyId, Value
:
public class MyObj
{
public int Id { get; set; }
public int SomeProperty { get; set; }
public string AnotherProperty { get; set; }
}
DL, . , , (BaseTableProperty.Name == MyObj.<PropertyName>), .
, BaseTableProperty, BaseTableValue.
:
RecordId
1
PropertyId Name
1 SomeProperty
ValueId RecordId PropertyId Value
1 1 1 100
: , . , SomeProperty - typeof(MyObj).GetProperty("SomeProperty")? ? ? Int? , "100" int, :
propertyInfo.SetValue(myNewObjInstance, Convert.ChangeType(dbValue, propertyInfo.PropertyType), null);
.