Let's say I have a class called Test with one property called Title with a custom attribute:
public class Test
{
[DatabaseField("title")]
public string Title { get; set; }
}
And an extension method called DbField. I am wondering if getting a custom attribute from an object instance is even possible in c#.
Test t = new Test();
string fieldName = t.Title.DbField();
//fieldName will equal "title", the same name passed into the attribute above
Can this be done?
See Question&Answers more detail:os