I a writing a C# app that reads data from a text file that is divided into record types of fixed content. Sort of a text version of the old ISAM format. I then want to write out the data to an Access database that has a different table structure than the input file.
I am reading each record type of the input file into a separate class. I have the layout of each input record within the class definition that is then fed to a generic parser that loads the data into the class. All this works just fine.
The issue I have is cleanly creating the SQL insert statements to write to the Access database. The Access database has a different table structure than the input File. I would like to create a mapping of the columns within an Access table to the classes that contain the input data. e. g. output-table-A.column_C gets its data from input-record-1.column_1. I could then write a generic function to gather up the data for the insert SQL statement to load output-table-A.
The problem is that the reference to the input data objects would be a string. How do I get from a string to the actual instance of the object to retrieve the data?
This flexibility would be useful as some of the users will want to specify the mappings from input to output themselves within a file that would be read at run time by the program. I know this sounds strange, but I am dealing with a database schema that is allowed to be altered by users. Don't ask me why anyone would write a system that allowed such, but they did.