Red Gate forums :: View topic - How to avoid saving replication triggers to folder?
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

How to avoid saving replication triggers to folder?

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



Joined: 11 Jun 2010
Posts: 2

PostPosted: Fri Jun 11, 2010 11:54 am    Post subject: How to avoid saving replication triggers to folder? Reply with quote

I'm trying to use the Compare SDK to save my database objects to a disk folder. However I do not want replication triggers included. Have tried with Options.IgnoreReplicationTriggers (see below) but it does not seem have any effect.

Is this possible at all??

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RedGate.SQLCompare.Engine;
using RedGate.SQLCompare.Engine.ReadFromFolder;


namespace SourceGrabber
{
    class Program
    {
        static void Main(string[] args)
        {
            RedGate.SQLCompare.Engine.Database db;

            using (db = new Database())
            {
                db.Register(new ConnectionProperties(@"TheServer", "TheDatabase"), Options.Default | Options.IgnoreReplicationTriggers);
                db.SaveToFolder(@"TheDiskFolder", new WriteToFileOptions());
            }
        }
    }
}
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6649

PostPosted: Mon Jun 14, 2010 5:26 pm    Post subject: Reply with quote

Hi OJ,

It looks like you have to compare the database to the script folder and then merge the changes in order to skip the replication trigger. Loading the database and saving it to disk doesn't seem to respect options.
Code:
                            private const string c_WidgetProductionFolder = @"c:\users\me\My Documents\schema folders\widgetProduction";
widgetProduction.Register(new ConnectionProperties(".", @"widgetProduction"), Options.Default | Options.IgnoreReplicationTriggers);
                           Database wpScripts = new Database();
                           wpScripts.Register(c_WidgetProductionFolder, null, Options.Default | Options.IgnoreReplicationTriggers);
                           Differences diffs=widgetProduction.CompareWith(wpScripts, Options.Default | Options.IgnoreReplicationTriggers);
                           Work work = new Work();
                           ScriptSynchronizationActions actions = new ScriptSynchronizationActions();
                           work.BuildFromDifferences(diffs, Options.Default | Options.IgnoreReplicationTriggers, true);                   
                           ScriptSynchronizationActions scriptActions = work.ScriptSynchronizationActions;
                            scriptActions.Execute();
Back to top
View user's profile Send private message
OJ



Joined: 11 Jun 2010
Posts: 2

PostPosted: Tue Jun 15, 2010 9:14 am    Post subject: Reply with quote

Thanks for your reply Brian. Your work around should work.

However I concider it a defect, that the Register method does not respect the Options passed in.
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