I am building a CSV import library to import CSV with user defined mapping. How it will work is, user will be presented with UI to map CSV column with EF Table->Column (drag & drop or connecting lines between). Once this is done, library will import that CSV into the mapped tables.
Problem I have is, there will be about 40-50 tables (couple of tables with more than 40 columns) so I don't want to use switch or if. I will have string name of Table and column (using diff display name will be good but not required) with mapped csv column name (and index). From this, I want to import all the csv records. I also need to consider reference (foreign key) linking where CSV will contain foreign key value not id so I need to connect referenced table to get id.
I am think lambda expression with reflection may help but not sure how. I have looked at reply from Matt Searles but didn't quite understand how to use that and also don't know where's ToSeperatedString coming from. Also looked at CsvHelper but don't think that will be helpful when entity name is not known at design time.
Would appreciate any help. Thanks
Aucun commentaire:
Enregistrer un commentaire