I have some asp.net code that populates the fields in a LINQ to SQL object (all string fields) with values from a posted form:
userSelections.A = Request.Form["A"];
userSelections.B = Request.Form["B"];
userSelections.C = Request.Form["C"];
userSelections.D = Request.Form["D"];
I want to store the name of the form field and the associated setter object in a table, so I can iterate through the whole set without having to write a bunch of repeating code.
Is there a way to get a delegate to a property setter? i.e., say I have class myClass, with string property myProperty. Can I get a delegate, something like void myPropertySetterDelegate(string val, MyClass this), that can be used with any instance of the class?
I know this can be done with reflection, but other developers on my project have performance concerns, so I would prefer a non-reflection solution if possible.
Thanks!