customize this code

danjamandanjaman Posts: 12
edited July 10, 2007 12:15PM 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. :arrow:

Comments

  • Bringing my reply over from your topic on the version 6 forum...
    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.
    ...
Sign In or Register to comment.