Filtering - the new approach
jbaggaley
Posts: 38
What is the new approach to filtering (as shown by the example code for selecting tables which have a company id field of 1) because the object model no longer has a Table class (RedGate.SQLDataCompare.Engine.Table)?
Thanks
Jon
/* Get a list of tables with matching primary keys */ obCompareTables = RedGate.SQLDataCompare.Engine.Tables.CreateFromIntersection(dbSourceDatabase.Tables, dbTargetDatabase.Tables); /*Loop through all of the tables, and only select the tables that contain the field 'CompanyID' */ foreach (RedGate.SQLDataCompare.Engine.Table Table in obCompareTables) { if (Table.Fields["CompanyID"]!=null) obTableComparisonSettings.Add(obTCS = new SQLDataCompare.Engine.TableComparisonSetting(Table.FullyQualifiedName, Table.Fields, Table.PrimaryKey.Fields)); }
Thanks
Jon
:-)zz[
Comments
However this is not working because objects can't be removed from a collection being iterated.
Please can you point me to a new sample for table filtering.
Also, I noticed that there is a new Where clause which is only documented as existing but nothing about how to use it. Can it be used similar to the following?
if so, is it possible to do this before doing a table comparison so that in the case of our databases where we have multiple million row tables, we can restrict the amount of keys that the API has to look through?
Thanks
Jon
Hope this helps someone.
Sorry for the delay. We're all coming to grips with the new object model. If you simply want to exclude a table from a data compare, run through the mappings, and set the 'include' property of each mapping to 'false'.
Hope this helps!
updated version then as follows in case anyone needs it...
Now just need to work out the where clause object..