Missing Field from Where Clause

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

Missing Field from Where Clause

Postby jimmypooh » Fri Oct 15, 2010 7:40 pm

I'm using the compaire and passing it a where clause for each mapping. However, not all tabled have the field I'm using in the where clause. Is there a way to tell the comparer to ignore the where clause if it errors?

Or I guess the better question is how do I check the TableMapping if that particular where clause will be viable (ie if a certain field exists).
jimmypooh
 
Posts: 8
Joined: Tue Oct 12, 2010 2:17 pm

Postby james.billings » Mon Oct 18, 2010 1:34 pm

Thanks for your query.
There isn't a particularly quick way of doing this, but one option is as below:

Code: Select all
private static void AddWhereClause(TableMappings mappings)
      {
         foreach (TableMapping mapping in mappings)
         {
            if (mapping.Obj1.FullyQualifiedName=="[dbo].[ActionHistory]")
            {

                    foreach (FieldMapping m in mapping.FieldMappings)
                    {
                        if (m.Obj1.Name == "ActionDate")
                        {
                            mapping.Include = true;
                            mapping.Where = new WhereClause("RecordID>=2");
                        }
                    }
                }
            else
            {
               mapping.Include = false;
            }
         }
      }



In this instance, as I iterate around the mappings collection I'm checking for a certain table name. Within that check, I'm going through the fields collection to then see if a specific column exists.

You can perhaps tweak this so the column or table level check looks at your where clause to automate it to a certain extent.

Hope that helps.
james.billings
 
Posts: 1144
Joined: Wed Jun 16, 2010 11:10 am
Location: My desk.


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests