How to avoid saving replication triggers to folder?

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

How to avoid saving replication triggers to folder?

Postby OJ » Fri Jun 11, 2010 11:54 am

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: Select all
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());
            }
        }
    }
}
OJ
 
Posts: 2
Joined: Fri Jun 11, 2010 11:44 am

Postby Brian Donahue » Mon Jun 14, 2010 5:26 pm

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: Select all
                            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();
Brian Donahue
 
Posts: 6668
Joined: Mon Aug 23, 2004 10:48 am

Postby OJ » Tue Jun 15, 2010 9:14 am

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.
OJ
 
Posts: 2
Joined: Fri Jun 11, 2010 11:44 am


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests