using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Management.Smo;

namespace FilterCallback
{
    class Program
    {
        static void Main(string[] args)
        {
            Server server = new Server("CANOPUS5");
            UrnCollection urns = new UrnCollection();
            urns.Add(@"Server[@Name='CANOPUS5']/
                Database[@Name='AdventureWorks']/Table[@Name='Customer' and @Schema='Sales']");
            urns.Add(@"Server[@Name='CANOPUS5']/
                Database[@Name='AdventureWorks']/Table[@Name='SalesTerritory' and @Schema='Sales']");
            Scripter scripter = new Scripter(server);
            scripter.Options.ToFileOnly = true;
            scripter.Options.FileName = "script.sql";
            scripter.Options.WithDependencies = true;
            scripter.FilterCallbackFunction = delegate(Urn urn)
            {
                if (urns.Contains(urn))
                {
                    return false;
                }
                return true;
            };
            scripter.Script(urns);
        }
    }
}
