Comparing Table Fields
kriggs
Posts: 3
I am trying to compare only a few fields between two databases using SQL Toolkit 4. I see how to pass in the table.fields using:
settings.Add(new TableComparisonSetting(Table.FullyQualifiedName, Table.Fields, Table.PrimaryKey.Fields));
but I can not figure out how to set the Table.Fields to a subset of the available fields in the table.
Thanks in advance for any help that may be offered.
settings.Add(new TableComparisonSetting(Table.FullyQualifiedName, Table.Fields, Table.PrimaryKey.Fields));
but I can not figure out how to set the Table.Fields to a subset of the available fields in the table.
Thanks in advance for any help that may be offered.
Comments
:idea:
The code below goes through a collection of common tables and if the common table is selected for comparson creates a new table object and loops through the fields checking to ensure that they are marked for comparison and adding them to a table.Fields property of the table object, which is then passed to the New TableComparisonSettings.
foreach (Table table in commonTables)
{
if (ct.m_alTables.Contains(table.Name))
{
Table inputTable = new Table(table.Owner, table.Name);
IEnumerator iFields = table.Fields.GetEnumerator();
ct.GetComparableColumns(table);
int i = 0;
while (iFields.MoveNext())
{
Field tableField = table.Fields;
if (ct.m_alTableColumns.Contains(tableField.Name) || table.PrimaryKey.Fields.ContainsField(tableField.Name.ToString()))
{
inputTable.Fields.Add(tableField);
}
i++;
}
settings.Add(new TableComparisonSetting(inputTable.FullyQualifiedName, inputTable.Fields, table.PrimaryKey.Fields));
}
}