I have a requirement to copy the tables from one DB to another . The table names (to be used in the application) are configured in the XML file.
This works out 开发者_C百科if the tables doesn't have any relations. In case any of the tables have relations. What is the best way to proceed?
- How to decide the XML schema? (how to specify master tables, if they are in turn dependent on other tables)
- How to effectively parse the XML schema in C#, so that the master tables are loaded first.
Thanks, Vijay
2.How to effectively parse the XML schema in C#, so that the master tables are loaded first.
NOT AT ALL. This is a toy data set (i.e. small), just use the Xml Serializer. No need to write parser.
1.How to decide the XML schema? (how to specify master tables, if they are in turn dependent on other tables)
Experience, requrements and KISS principle. Sorry, this is so basic I dont know what else to write.
Using linq-to-sql, it is possible to have an external mapping in xml format between the classes and their properties and the table and column names they map to. Linq-to-sql have features for foreign key references etc. built in.
Using an external mapping source, you will have to do some work by hand. The basic steps are:
- Create the database if not already created.
- Write classes with the names that you want to use in the code. You could possibly use the SqlMetal tool to generate raw files that you can strip from mapping attributes.
- Write an xml mapping file.
If you are not familiar with linq-to-sql I would recommend you to start with a toy project using the Visual Studio Designer, to quickly get started to get familiar with the technology.
精彩评论