In my class I have private variables and properties like this.
private string _itemCOde=string.Empty;
private string _itemName=string.Empty;
public string ItemCode
{
get { return _itemCode; }
set { _itemCode = value == null ? value : value.Trim();}
}
public string ItemName
{
get { return _itemName; }
set { _itemName = value == null ? value : value.Trim();}
}
According to this properties I create Item objects after selecting the data from the sql table.
Now, if database table altered and add a new column called cost, then I have to add another property to the class. Without adding new properties to the class is there any way do declare properties according to the table fields dynamically.
You could use an
ExpandoObject: