Getting data from a database table to an object in code has always seemed like mundane code. There are two ways I have found to do it:
- have a code generator that reads a database table and creates the class and controller to map the datafields to the class fields or
- use reflection to take the database field and find it on the class.
The problems noted with the above 2 methods are as noted below
- Method 1 seems to me like I'm missing something because I have to create a controller for every table.
- Method 2 seems to be too labor intensive once you get into heavy data access code.
Is there a third route that I should try to get data from a database onto my objects?