Red Gate forums :: View topic - Missing Field from Where Clause
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Comparison SDK Previous Versions
SQL Comparison SDK Previous Versions forum

Missing Field from Where Clause

Search in SQL Comparison SDK Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
jimmypooh



Joined: 12 Oct 2010
Posts: 8

PostPosted: Fri Oct 15, 2010 7:40 pm    Post subject: Missing Field from Where Clause Reply with quote

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).
Back to top
View user's profile Send private message
james.billings



Joined: 16 Jun 2010
Posts: 1116
Location: My desk.

PostPosted: Mon Oct 18, 2010 1:34 pm    Post subject: Reply with quote

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

Code:

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group