customize this code

danjamandanjaman Posts: 12
edited July 10, 2007 11:51AM in SQL Toolkit Previous Versions
Here is my C# code
                mappings.CreateMappings(db1.Tables, db2.Tables);
                session.CompareDatabases(db1, db2, mappings);

as db1.tables I want to make it read from my config file setting called section

and as db2.tables I also want it to read as section.

My config file has sectionGroup
and section which is the list of tables be sectionGroup.

ho to do this. 8)

Comments

  • This you would have to do using your own code to parse apart your config file.


    Instead of mappings.CreateMappings(db1.Tables, db2.Tables), you would code to add each TableMapping to the TableMappings individually.

    That is:
    TableMappings mappings = new TableMappings();
    mappings.Join(db1.Tables["[dbo].[myTable]"], db2.Tables["[dbo].[myTable]"]);
    
    using(ComparisonSession session = new ComparisonSession()){
    session.CompareDatabases(db1, db2, mappings);
    }
    

    Thats just an example of how to add one Table to Table mapping. When you do it individually like that, you can map Views to Views or even Tables to Views. You should parse your list of tables into a list of strings, and iterate through it, joining each individually using mappings.Join(...).

    Note the format of a table name, it is fully qualified, specifying both the schema(owner) and table name like: "[dbo].[myTable]"

    Once again, I don't work for Red Gate, but I've become pretty familiar with the toolkit.

    That being said, I'm using knowledge gained from version 5.3, not 6.0. If you are using a previous version, you might want this topic moved to the old forum. My knowledge might not work with the new libraries.
Sign In or Register to comment.