MergeArticle 클래스

정의

병합 게시의 아티클을 나타냅니다.

public ref class MergeArticle sealed : Microsoft::SqlServer::Replication::Article
public sealed class MergeArticle : Microsoft.SqlServer.Replication.Article
type MergeArticle = class
    inherit Article
Public NotInheritable Class MergeArticle
Inherits Article
상속

예제

이 예제에서는 세 개의 병합 아티클과 관련 조인 필터를 만듭니다.

// Define the Publisher and publication names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";

// Specify article names.
string articleName1 = "Employee";
string articleName2 = "SalesOrderHeader";
string articleName3 = "SalesOrderDetail";

// Specify join filter information.
string filterName12 = "SalesOrderHeader_Employee";
string filterClause12 = "Employee.EmployeeID = " +
    "SalesOrderHeader.SalesPersonID";
string filterName23 = "SalesOrderDetail_SalesOrderHeader";
string filterClause23 = "SalesOrderHeader.SalesOrderID = " +
    "SalesOrderDetail.SalesOrderID";

string salesSchema = "Sales";
string hrSchema = "HumanResources";

MergeArticle article1 = new MergeArticle();
MergeArticle article2 = new MergeArticle();
MergeArticle article3 = new MergeArticle();
MergeJoinFilter filter12 = new MergeJoinFilter();
MergeJoinFilter filter23 = new MergeJoinFilter();

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

// Create three merge articles that are horizontally partitioned
// using a parameterized row filter on Employee.EmployeeID, which is 
// extended to the two other articles using join filters. 
try
{
    // Connect to the Publisher.
    conn.Connect();

    // Create each article. 
    // For clarity, each article is defined separately. 
    // In practice, iterative structures and arrays should 
    // be used to efficiently create multiple articles.

    // Set the required properties for the Employee article.
    article1.ConnectionContext = conn;
    article1.Name = articleName1;
    article1.DatabaseName = publicationDbName;
    article1.SourceObjectName = articleName1;
    article1.SourceObjectOwner = hrSchema;
    article1.PublicationName = publicationName;
    article1.Type = ArticleOptions.TableBased;

    // Define the parameterized filter clause based on Hostname.
    article1.FilterClause = "Employee.LoginID = HOST_NAME()";

    // Set the required properties for the SalesOrderHeader article.
    article2.ConnectionContext = conn;
    article2.Name = articleName2;
    article2.DatabaseName = publicationDbName;
    article2.SourceObjectName = articleName2;
    article2.SourceObjectOwner = salesSchema;
    article2.PublicationName = publicationName;
    article2.Type = ArticleOptions.TableBased;

    // Set the required properties for the SalesOrderDetail article.
    article3.ConnectionContext = conn;
    article3.Name = articleName3;
    article3.DatabaseName = publicationDbName;
    article3.SourceObjectName = articleName3;
    article3.SourceObjectOwner = salesSchema;
    article3.PublicationName = publicationName;
    article3.Type = ArticleOptions.TableBased;

    if (!article1.IsExistingObject) article1.Create();
    if (!article2.IsExistingObject) article2.Create();
    if (!article3.IsExistingObject) article3.Create();

    // Select published columns for SalesOrderHeader.
    // Create an array of column names to vertically filter out.
    // In this example, only one column is removed.
    String[] columns = new String[1];

    columns[0] = "CreditCardApprovalCode";

    // Remove the column.
    article2.RemoveReplicatedColumns(columns);

    // Define a merge filter clauses that filter 
    // SalesOrderHeader based on Employee and 
    // SalesOrderDetail based on SalesOrderHeader. 

    // Parent article.
    filter12.JoinArticleName = articleName1;
    // Child article.
    filter12.ArticleName = articleName2;
    filter12.FilterName = filterName12;
    filter12.JoinUniqueKey = true;
    filter12.FilterTypes = FilterTypes.JoinFilter;
    filter12.JoinFilterClause = filterClause12;

    // Add the join filter to the child article.
    article2.AddMergeJoinFilter(filter12);

    // Parent article.
    filter23.JoinArticleName = articleName2;
    // Child article.
    filter23.ArticleName = articleName3;
    filter23.FilterName = filterName23;
    filter23.JoinUniqueKey = true;
    filter23.FilterTypes = FilterTypes.JoinFilter;
    filter23.JoinFilterClause = filterClause23;

    // Add the join filter to the child article.
    article3.AddMergeJoinFilter(filter23);
}
catch (Exception ex)
{
    // Do error handling here and rollback the transaction.
    throw new ApplicationException(
        "The filtered articles could not be created", ex);
}
finally
{
    conn.Disconnect();
}
' Define the Publisher and publication names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"

' Specify article names.
Dim articleName1 As String = "Employee"
Dim articleName2 As String = "SalesOrderHeader"
Dim articleName3 As String = "SalesOrderDetail"

' Specify join filter information.
Dim filterName12 As String = "SalesOrderHeader_Employee"
Dim filterClause12 As String = "Employee.EmployeeID = " + _
    "SalesOrderHeader.SalesPersonID"
Dim filterName23 As String = "SalesOrderDetail_SalesOrderHeader"
Dim filterClause23 As String = "SalesOrderHeader.SalesOrderID = " + _
    "SalesOrderDetail.SalesOrderID"

Dim salesSchema As String = "Sales"
Dim hrSchema As String = "HumanResources"

Dim article1 As MergeArticle = New MergeArticle()
Dim article2 As MergeArticle = New MergeArticle()
Dim article3 As MergeArticle = New MergeArticle()
Dim filter12 As MergeJoinFilter = New MergeJoinFilter()
Dim filter23 As MergeJoinFilter = New MergeJoinFilter()

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

' Create three merge articles that are horizontally partitioned
' using a parameterized row filter on Employee.EmployeeID, which is 
' extended to the two other articles using join filters. 
Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Create each article. 
    ' For clarity, each article is defined separately. 
    ' In practice, iterative structures and arrays should 
    ' be used to efficiently create multiple articles.

    ' Set the required properties for the Employee article.
    article1.ConnectionContext = conn
    article1.Name = articleName1
    article1.DatabaseName = publicationDbName
    article1.SourceObjectName = articleName1
    article1.SourceObjectOwner = hrSchema
    article1.PublicationName = publicationName
    article1.Type = ArticleOptions.TableBased

    ' Define the parameterized filter clause based on Hostname.
    article1.FilterClause = "Employee.LoginID = HOST_NAME()"

    ' Set the required properties for the SalesOrderHeader article.
    article2.ConnectionContext = conn
    article2.Name = articleName2
    article2.DatabaseName = publicationDbName
    article2.SourceObjectName = articleName2
    article2.SourceObjectOwner = salesSchema
    article2.PublicationName = publicationName
    article2.Type = ArticleOptions.TableBased

    ' Set the required properties for the SalesOrderDetail article.
    article3.ConnectionContext = conn
    article3.Name = articleName3
    article3.DatabaseName = publicationDbName
    article3.SourceObjectName = articleName3
    article3.SourceObjectOwner = salesSchema
    article3.PublicationName = publicationName
    article3.Type = ArticleOptions.TableBased

    ' Create the articles, if they do not already exist.
    If article1.IsExistingObject = False Then
        article1.Create()
    End If
    If article2.IsExistingObject = False Then
        article2.Create()
    End If
    If article3.IsExistingObject = False Then
        article3.Create()
    End If

    ' Select published columns for SalesOrderHeader.
    ' Create an array of column names to vertically filter out.
    ' In this example, only one column is removed.
    Dim columns() As String = New String(0) {}

    columns(0) = "CreditCardApprovalCode"

    ' Remove the column.
    article2.RemoveReplicatedColumns(columns)

    ' Define a merge filter clauses that filter 
    ' SalesOrderHeader based on Employee and 
    ' SalesOrderDetail based on SalesOrderHeader. 

    ' Parent article.
    filter12.JoinArticleName = articleName1
    ' Child article.
    filter12.ArticleName = articleName2
    filter12.FilterName = filterName12
    filter12.JoinUniqueKey = True
    filter12.FilterTypes = FilterTypes.JoinFilter
    filter12.JoinFilterClause = filterClause12

    ' Add the join filter to the child article.
    article2.AddMergeJoinFilter(filter12)

    ' Parent article.
    filter23.JoinArticleName = articleName2
    ' Child article.
    filter23.ArticleName = articleName3
    filter23.FilterName = filterName23
    filter23.JoinUniqueKey = True
    filter23.FilterTypes = FilterTypes.JoinFilter
    filter23.JoinFilterClause = filterClause23

    ' Add the join filter to the child article.
    article3.AddMergeJoinFilter(filter23)

Catch ex As Exception
    ' Do error handling here and rollback the transaction.
    Throw New ApplicationException( _
        "The filtered articles could not be created", ex)
Finally
    conn.Disconnect()
End Try

이 예제에서는 비즈니스 논리 처리기를 아티클과 연결하도록 및 기존 병합 문서를 변경합니다. 자세한 내용은 sp_helpmergearticlecolumn(Transact-SQL))를 참조하세요.

// Define the Publisher, publication, and article names.
string publisherName = publisherInstance;
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2012";
string articleName = "SalesOrderHeader";

// Set the friendly name of the business logic handler.
string customLogic = "OrderEntryLogic";

MergeArticle article = new MergeArticle();

// Create a connection to the Publisher.
ServerConnection conn = new ServerConnection(publisherName);

try
{
    // Connect to the Publisher.
    conn.Connect();

    // Set the required properties for the article.
    article.ConnectionContext = conn;
    article.Name = articleName;
    article.DatabaseName = publicationDbName;
    article.PublicationName = publicationName;

    // Load the article properties.
    if (article.LoadProperties())
    {
        article.ArticleResolver = customLogic;
    }
    else
    {
        // Throw an exception of the article does not exist.
        throw new ApplicationException(String.Format(
        "{0} is not published in {1}", articleName, publicationName));
    }
    
}
catch (Exception ex)
{
    // Do error handling here and rollback the transaction.
    throw new ApplicationException(String.Format(
        "The business logic handler {0} could not be associated with " +
        " the {1} article.",customLogic,articleName), ex);
}
finally
{
    conn.Disconnect();
}
' Define the Publisher, publication, and article names.
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"
Dim articleName As String = "SalesOrderHeader"

' Set the friendly name of the business logic handler.
Dim customLogic As String = "OrderEntryLogic"

Dim article As MergeArticle = New MergeArticle()

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Set the required properties for the article.
    article.ConnectionContext = conn
    article.Name = articleName
    article.DatabaseName = publicationDbName
    article.PublicationName = publicationName

    ' Load the article properties.
    If article.LoadProperties() Then
        article.ArticleResolver = customLogic
    Else
        ' Throw an exception of the article does not exist.
        Throw New ApplicationException(String.Format( _
         "{0} is not published in {1}", articleName, publicationName))
    End If

Catch ex As Exception
    ' Do error handling here and rollback the transaction.
    Throw New ApplicationException(String.Format( _
     "The business logic handler {0} could not be associated with " + _
     " the {1} article.", customLogic, articleName), ex)
Finally
    conn.Disconnect()
End Try

설명

스레드 보안

이 유형의 모든 공용 정적(Shared Microsoft Visual Basic의 경우) 멤버는 다중 스레드 작업에 안전합니다. 인스턴스 구성원은 스레드로부터의 안전성이 보장되지 않습니다.

생성자

MergeArticle()

MergeArticle 클래스의 새 인스턴스를 만듭니다.

MergeArticle(String, String, String, ServerConnection)

지정된 이름, 게시, 데이터베이스 및 Microsoft SQL Server 인스턴스에 대한 연결을 사용하여 클래스의 새 MergeArticle 인스턴스를 만듭니다.

속성

AllowInteractiveResolver

동기화 중에 충돌이 발생할 경우 구독에서 대화형 해결 프로그램을 호출할 수 있는지 여부를 가져오거나 설정합니다.

ArticleId

아티클 ID 값을 가져옵니다.

(다음에서 상속됨 Article)
ArticleResolver

아티클을 동기화할 때 사용되는 비즈니스 논리 처리기 또는 사용자 지정 충돌 해결 프로그램의 이름을 가져오거나 설정합니다.

CachePropertyChanges

복제 속성에 대한 변경 내용을 캐시할지 아니면 즉시 적용할지를 가져오거나 설정합니다.

(다음에서 상속됨 ReplicationObject)
CheckPermissions

구독자에서 변경 내용이 업로드되기 전에 게시자에서 사용 권한이 확인되는 방식을 가져오거나 설정합니다.

ColumnTracking

데이터 행을 동기화할 때 충돌을 검색하는 방법을 가져오거나 설정합니다.

CompensateForErrors

동기화 중에 오류가 발생할 경우 보상 동작을 수행할지 여부를 가져오거나 설정합니다.

ConflictTable

병합 아티클을 동기화할 때 발생하는 충돌을 추적하는 데 사용되는 테이블의 이름을 가져옵니다.

ConnectionContext

Microsoft SQL Server 인스턴스에 대한 연결을 가져오거나 설정합니다.

(다음에서 상속됨 ReplicationObject)
CreateArticleAsHeterogeneous

아티클을 다른 유형으로 만들지 여부를 나타내는 값을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
CreationScript

구독자에서 대상 개체를 만드는 데 사용되는 Transact-SQL 스크립트 파일의 이름과 전체 경로를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
DatabaseName

아티클에 게시되는 개체 및 데이터를 포함하는 데이터베이스의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
DeleteTracking

삭제 내용이 복제되는지 여부를 가져오거나 설정합니다.

Description

아티클에 대한 텍스트 설명을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
DestinationObjectName

구독자에서 아티클에 대한 원본 데이터베이스 개체로 사용되는 데이터베이스 개체를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
DestinationObjectOwner

구독자에서 아티클에 대한 원본 데이터베이스 개체의 스키마 소유자를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
FilterClause

아티클을 가로로 필터링하도록 평가되는 WHERE(Transact-SQL) 절을 가져오거나 설정합니다.

IdentityRangeManagementOption

아티클에 대한 ID 범위 관리 옵션을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
IdentityRangeThreshold

새 범위의 ID 열 값이 게시자 또는 구독자에 할당되는 값을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
IsExistingObject

서버에 개체가 있는지 여부를 가져옵니다.

(다음에서 상속됨 ReplicationObject)
MultipleColumnUpdate

복수 열을 업데이트할지 여부를 나타내는 값을 가져오거나 설정합니다.

Name

아티클 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
PartitionOption

매개 변수가 있는 행 필터를 사용하여 아티클이 필터링되는 경우 필터링 옵션을 가져오거나 설정합니다.

PreCreationMethod

게시된 개체가 구독 데이터베이스에 이미 있는 경우 수행할 동작을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
ProcessingOrder

동기화 중에 아티클 처리 순서를 가져오거나 설정합니다.

PublicationName

아티클이 속한 게시의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
PublisherIdentityRangeSize

게시자의 테이블 열에 할당된 ID 값의 범위를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
ResolverInfo

COM 기반 충돌 해결 프로그램에 사용할 추가 데이터 및 매개 변수를 가져오거나 설정합니다.

SchemaOption

아티클에 대한 스키마 만들기 옵션을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
SnapshotObjectName

아티클에 대한 초기 스냅샷 데이터를 나타내는 데이터베이스 개체의 이름을 가져옵니다.

SnapshotObjectOwner

아티클에 대한 초기 스냅샷 데이터를 나타내는 데이터베이스 개체의 소유자를 가져옵니다.

SourceObjectName

게시되는 데이터베이스 개체의 이름을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
SourceObjectOwner

게시되는 데이터베이스 개체의 소유자를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
SqlServerName

이 개체가 연결된 Microsoft SQL Server 인스턴스의 이름을 가져옵니다.

(다음에서 상속됨 ReplicationObject)
Status

병합 아티클의 상태를 가져오거나 설정합니다.

StreamBlobColumns

BLOB(Binary Large Object) 열을 복제할 때 데이터 스트림 최적화를 사용할지 여부를 가져오거나 설정합니다.

SubscriberIdentityRangeSize

다른 ID 범위를 할당해야 하기 전에 구독자에서 테이블의 ID 열에 삽입할 수 있는 최대 새 행 수를 가져오거나 설정합니다.

(다음에서 상속됨 Article)
SubscriberUploadOption

클라이언트 구독을 사용하는 구독자에서 수행되는 업데이트 동작을 가져오거나 설정합니다.

Type

아티클 유형을 가져오거나 설정합니다.

(다음에서 상속됨 Article)
UserData

사용자가 자신의 고유 데이터를 개체에 연결할 수 있도록 하는 개체 속성을 가져오거나 설정합니다.

(다음에서 상속됨 ReplicationObject)
VerifyResolverSignature

COM 기반 충돌 해결 프로그램의 디지털 서명이 제공된 원본을 신뢰할 수 있는지 여부를 확인하는 옵션을 가져오거나 설정합니다.

VerticalPartition

모든 열이 테이블 아티클에 게시되는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Article)

메서드

AddMergeJoinFilter(MergeJoinFilter)

병합 아티클에 조인 필터를 추가합니다.

AddReplicatedColumns(Array)

병합 아티클에 지정된 열을 추가합니다.

ChangeMergeJoinFilter(MergeJoinFilter, MergeJoinFilter)

병합 아티클에 정의된 조인 필터를 변경합니다.

CheckValidCreation()

유효한 아티클 생성을 확인합니다.

(다음에서 상속됨 Article)
CheckValidDefinition(Boolean)

정의가 유효한지 여부를 나타냅니다.

(다음에서 상속됨 Article)
CommitPropertyChanges()

캐시된 모든 속성 변경 문을 Microsoft SQL Server 인스턴스로 보냅니다.

(다음에서 상속됨 ReplicationObject)
Create()

개체 또는 개체의 현재 속성을 기반으로 현재 연결된 SQL Server 인스턴스에 새 아티클을 TransArticleMergeArticle 만듭니다.

(다음에서 상속됨 Article)
Decouple()

참조된 복제 개체를 서버에서 분리합니다.

(다음에서 상속됨 ReplicationObject)
EnumMergeJoinFilters()

병합 아티클에 대해 정의된 조인 필터를 반환합니다.

GetChangeCommand(StringBuilder, String, String)

복제에서 변경 명령을 반환합니다.

(다음에서 상속됨 ReplicationObject)
GetCreateCommand(StringBuilder, Boolean, ScriptOptions)

복제에서 생성 명령을 반환합니다.

(다음에서 상속됨 ReplicationObject)
GetDropCommand(StringBuilder, Boolean)

복제에서 삭제 명령을 반환합니다.

(다음에서 상속됨 ReplicationObject)
InitializeSharedPropertiesBasedOnExistingArticles()

기존 아티클에 따라 공유 속성을 초기화하는지 여부를 나타냅니다.

InternalRefresh(Boolean)

복제에서 내부 새로 고침을 시작합니다.

(다음에서 상속됨 ReplicationObject)
ListReplicatedColumns()

수직 분할된 아티클에 있는 열을 반환합니다.

Load()

서버에서 기존 개체의 속성을 로드합니다.

(다음에서 상속됨 ReplicationObject)
LoadProperties()

서버에서 기존 개체의 속성을 로드합니다.

(다음에서 상속됨 ReplicationObject)
Refresh()

개체의 속성을 다시 로드합니다.

(다음에서 상속됨 ReplicationObject)
Remove()

개체 또는 개체의 현재 속성을 기반으로 현재 연결된 SQL Server 인스턴스에서 기존 아티클을 TransArticleMergeArticle 제거합니다.

(다음에서 상속됨 Article)
RemoveMergeJoinFilter(String)

아티클에서 지정된 병합 조인 필터를 제거합니다.

RemoveReplicatedColumns(Array)

수직 분할된 아티클에서 기존 열을 제거합니다.

Script(ScriptOptions)

서버에서 개체 또는 개체를 만들거나 삭제 TransArticle 하기 위해 실행할 수 있는 Transact-SQL 스크립트를 MergeArticle 생성합니다.

(다음에서 상속됨 Article)
ScriptMergeJoinFilter(MergeJoinFilter, ScriptOptions)

병합 아티클에 연결된 병합 조인 필터의 Transact-SQL 스크립트를 반환합니다.

적용 대상

추가 정보