I'm looking for a method to change column and field names dynamically/programatically;
as:
string iLoadProfileValue = "ColumnName";
string lastCol = DatabaseFunctions.DatabaseClient
.tbl_MeterLoadProfile
.OrderByDescending(a => a.MeterReadDate)
.FirstOrDefault(a => a.MeterID == meterID).iLoadProfileValue;
I'll change iLoadProfileValue's value programatically. And I would like to get that column's value to lastCol variable.
How can it be done?
Thanks a lot.
Done:
Last situation like this: THANKS to thepirat000 and Dismissile
string iLoadProfileValue = "MeterReadDate";
var myEntity = DatabaseFunctions.DatabaseClient.tbl_MeterLoadProfile.OrderByDescending(a => a.MeterReadDate).FirstOrDefault(a => a.MeterID == 6);
if (myEntity != null)
{
var properties = myEntity.GetType().GetProperty(iLoadProfileValue);
object value = properties.GetValue(myEntity);
}