A data set containing a collection of rows.
Namespace:
RedGate.SQLDataCompare.Engine.ResultsStore
Assembly:
RedGate.SQLDataCompare.Engine (in RedGate.SQLDataCompare.Engine.dll)
Syntax
Remarks
Examples
Printing out different records in a table.
C# | Copy Code |
---|
using System;
using RedGate.SQLCompare.Engine;
using RedGate.SQLDataCompare.Engine;
using RedGate.SQLDataCompare.Engine.ResultsStore;
namespace SQLDataCompareCodeSnippets
{
/// <summary>
/// Summary description for StoreExample.
/// </summary>
public class StoreExample
{
public void RunExample()
{
Database db1=new Database();
Database db2=new Database();
db1.RegisterForDataCompare(new ConnectionProperties(".", "WidgetDev"));
db2.RegisterForDataCompare(new ConnectionProperties(".", "WidgetLive"));
using(ComparisonSession session=new ComparisonSession())
{
// Create the mappings between the two databases
TableMappings mappings = new TableMappings();
mappings.CreateMappings(db1.Tables, db2.Tables);
session.CompareDatabases(db1, db2, mappings);
Reader resultsReader=session.TableDifferences["[dbo].[Widgets]"].ResultsStore.GetReader();
// work out the two positions in the fields
int description1=resultsReader.Fields["Description"].OrdinalInResults1;
int description2=resultsReader.Fields["Description"].OrdinalInResults2;
// work out the position of the RecordID column
// this is part of the unique index we are comparing on
int recordID=resultsReader.Fields["RecordID"].OrdinalInResults1;
// sort by description in the first database
resultsReader.SortOrder.ColumnSorts.Add(new ColumnSort(resultsReader.Fields["Description"], true));
resultsReader.ApplySort();
foreach(Row row in resultsReader)
{
Console.Write("{0}:{1},{2}", row.Values[recordID], row.Values[description1], row.Values[description2]);
Console.WriteLine();
}
}
db1.Dispose();
db2.Dispose();
}
}
}
|
Visual Basic | Copy Code |
---|
Option Explicit On
Imports RedGate.SQLCompare.Engine
Imports RedGate.SQLDataCompare.Engine
Imports RedGate.SQLDataCompare.Engine.ResultsStore
Public Class StoreExample
Sub RunExample()
Dim session As New ComparisonSession
'register the databases for comparison
Dim db1 As New Database
Dim db2 As New Database
db1.RegisterForDataCompare(New ConnectionProperties(".", "WidgetDev"))
db2.RegisterForDataCompare(New ConnectionProperties(".", "WidgetLive"))
'create an intersection of the tables
Dim mappings As New TableMappings
mappings.CreateMappings(db1.Tables, db2.Tables)
'compare the databases
session.CompareDatabases(db1, db2, mappings)
Dim resultsReader As Reader = session.TableDifferences("[dbo].[Widgets]").ResultsStore.GetReader
'work out the two positions in the fields
Dim description1 As Integer = resultsReader.Fields("Description").OrdinalInResults1
Dim description2 As Integer = resultsReader.Fields("Description").OrdinalInResults2
'work out the position of the RecordID column
'this is part of the unique index we are comparing on
Dim recordID As Integer = resultsReader.Fields("RecordID").OrdinalInResults1
'sort by description in the first database
resultsReader.SortOrder.ColumnSorts.Add(New ColumnSort(resultsReader.Fields("Description"), True))
resultsReader.ApplySort()
Dim row As Row
For Each row In resultsReader
Console.Write("{0}:{1},{2}", row.Values(recordID), row.Values(description1), row.Values(description2))
Console.WriteLine()
Next
'dispose of the objects to delete temporary files
session.Dispose()
db1.Dispose()
db2.Dispose()
End Sub
End Class
|
Inheritance Hierarchy
See Also