STK 3 - Programmatically choose the compared data columns
Brian Donahue
Posts: 6,590 Bronze 1
- Date: 8 October 2004
- Affected Versions: RedGate.SQLDataCompare.Engine.dll 3.x
In the example application, find these lines of code:
Add to this a new instance of RedGate.SQLDataCompare.Engine.Fields, then populate this object with the names of the columns that you want to compare using its' Add() method. Finally, pass in the Fields() that you had created to the SessionSettings as an argument to a new TableComparisonSetting.//set up the table comparison setting
TableComparisonSettings settings=new TableComparisonSettings();
foreach (Table table in commonTables)
{
settings.Add(new TableComparisonSetting(table.FullyQualifiedName, table.Fields, table.PrimaryKey.Fields));
}
Here is an example:
foreach (Table table in commonTables)
{
if (table.FullyQualifiedName=="foo") {
Fields fc = new Fields();
foreach (Field f in table.Fields)
{
if (f.Name!="bar") fc.Add(f);
}
settings.Add(new TableComparisonSetting(table.FullyQualifiedName, fc, table.PrimaryKey.Fields));
}
else settings.Add(new TableComparisonSetting(table.FullyQualifiedName, table.Fields, table.PrimaryKey.Fields));
}
In this example, the 'bar' column is excluded from the comparison of the table called 'foo'. In all other tables, all columns are compared. The logic can easily be reversed to include a collection of columns rather than exclude them.