A SQL Data Compare project.

Namespace:  RedGate.SQLDataCompare.Engine
Assembly:  RedGate.SQLDataCompare.Engine (in RedGate.SQLDataCompare.Engine.dll)

Syntax

Visual Basic (Declaration)
Public Class Project _
	Implements IEquatable(Of Project)
C#
public class Project : IEquatable<Project>
Visual C++
public ref class Project : IEquatable<Project^>

Remarks

This class provides an easy way to load and save comparison settings.

Examples

Saving a project to, and loading from, disk
C# Copy Code
            using System;
            using RedGate.SQLCompare.Engine;
            using RedGate.SQLDataCompare.Engine;
            using Project = RedGate.SQLDataCompare.Engine.Project;
             
            namespace SQLDataCompareCodeSnippets
            {
                /// <summary>
                /// Summary description for ProjectExample.
                /// </summary>
                public class ProjectExample
                {
                    public void RunExample()
                    {
                        Project project=new Project();
                             
                        project.DataSource1.DatabaseName = "WidgetDev";            
                        project.DataSource2.DatabaseName = "WidgetLive";            
                        project.SessionSettings = SessionSettings.Default;
                        project.Options = new EngineDataCompareOptions(MappingOptions.Default,ComparisonOptions.Default, SqlOptions.Default);
                        Console.WriteLine("Saving project");            
                        project.SaveToDisk(@"c:\testproject.sdc");
                
                        //load up the project
                        Project project2=Project.LoadFromDisk(@"c:\testproject.sdc");
                        Console.WriteLine("Project loaded");
                
                        //get the two databases
                        Database db1= new Database();
                        Database db2= new Database();
                        SchemaMappings mappings = new SchemaMappings();
                
                        //Should check if this is true
                        LiveDatabaseSource liveDb = project2.DataSource1 as LiveDatabaseSource;
                        db1.RegisterForDataCompare(liveDb.ToConnectionProperties());
             
                        //Should check if this is true
                        liveDb = project2.DataSource2 as LiveDatabaseSource;
                        db2.RegisterForDataCompare(liveDb.ToConnectionProperties());
                
                        mappings.Options = project2.Options;
                        mappings.CreateMappings(db1, db2);
                 
                        //Disable any mappings here that you may want....
                        ComparisonSession session=new ComparisonSession();
                        session.Options = project2.Options;
                        session.CompareDatabases(db1, db2, mappings);
                
                        Console.WriteLine("Comparison run");
                    }
                }
            }
                
Visual Basic Copy Code
            Option Explicit On
            
            Imports RedGate.SQLCompare.Engine
            Imports RedGate.SQLDataCompare.Engine
            Imports Project = RedGate.SQLDataCompare.Engine.Project
             
            Public Class ProjectExample
                Sub RunExample()
                    Dim project As New Project
             
                    project.DataSource1.DatabaseName = "WidgetDev"
                    project.DataSource2.DatabaseName = "WidgetLive"
                    project.SessionSettings = SessionSettings.Default
                    project.Options = New EngineDataCompareOptions(MappingOptions.Default, ComparisonOptions.Default, SqlOptions.Default)
                    Console.WriteLine("Saving project")
                    project.SaveToDisk("c:\testproject.sdc")
             
                    'load up the project
                    Dim project2 As Project = project.LoadFromDisk("c:\testproject.sdc")
                    Console.WriteLine("Project loaded")
             
                    'get the two databases
                    Dim db1 As New Database
                    Dim db2 As New Database
                    Dim mappings As New SchemaMappings
             
                    'Should check if this is true
                    Dim livedb As LiveDatabaseSource = DirectCast(project2.DataSource1, LiveDatabaseSource)
                    db1.RegisterForDataCompare(livedb.ToConnectionProperties())
             
                    'Should check if this is true
                    livedb = DirectCast(project2.DataSource2, LiveDatabaseSource)
                    db2.RegisterForDataCompare(livedb.ToConnectionProperties())
             
                    mappings.Options = project2.Options
                    mappings.CreateMappings(db1, db2)
             
                    'Disable any mappings here that you may want....
                    Dim session As New ComparisonSession
                    session.Options = project2.Options
                    session.CompareDatabases(db1, db2, mappings)
             
                    Console.WriteLine("Comparison run")
                End Sub
            End Class
                

Inheritance Hierarchy

System..::.Object
  RedGate.SQLDataCompare.Engine..::.Project

See Also