What's the easiest way to generate code dynamically in .NET 4.5?
问题 I'm writing a specific kind of object-mapper. Basically I want to convert from a DataTable that has the fields a , b and c to an object that has properties a , b and c (the class of the object will be written by hand). There will be many different DataTables and many different classes that they will need to map to, so I want to make a generic mechanism that performs this data copying. Basically, I want the following function: public T Map<T>(DataTable t) where T: new() { ... } Now, I can do