I'm using Entity Framework and here is what the metadata looks like for one of the tables.
[Column("pp_account")]
public string Account { get; set; }
[Column("pp_added")]
public DateTime? AddDate { get; set; }
[Column("pp_auser")]
public string AddUpdateUserName { get; set; }
[Column("pp_cfalt")]
public string AlternateForwardingNumber { get; set; }
I'm interested in getting the Column attribute name instead of the public name, i.e. display pp_added instead of "AddDate". Here is a foreach loop I've written so far that almost gets me there
foreach(var field in _personal.GetType().GetProperties())
{
sb.Append("\nName : " + field.Name + "\n");
sb.Append("Type : " + field.PropertyType.Name + "\n");
sb.Append("Attributes: " + field.Attributes + "\n");
sb.Append("Value : " + field.GetValue(_personal, null) + "\n");
}
Here is what is returned:
Name: AddDate
Type: Nullable'1
Attributes: None
Value: 5/2/2014 12:00:00 AM
What I would like to get returned is
Name: pp_added
Type: Date
Value: 5/2/2014 12:00:00 AM
How do I access the [Column("pp_added")]
to get pp_added
instead of the public Name
?