Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library

MergeJoinFilter Class

 

Applies To: SQL Server 2016 Preview

Represents a join filter or logical record relationship between to merge articles.

Namespace:   Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Rmo (in Microsoft.SqlServer.Rmo.dll)

System.Object
  Microsoft.SqlServer.Replication.MergeJoinFilter

public sealed class MergeJoinFilter

NameDescription
System_CAPS_pubmethodMergeJoinFilter()

Create a new instance of the MergeJoinFilter class.

NameDescription
System_CAPS_pubpropertyArticleName

Gets or sets the name of the child article filtered by the join filter.

System_CAPS_pubpropertyBaseTableName

Gets or sets the name of the table object against which the article is filtered.

System_CAPS_pubpropertyBaseTableOwner

Gets or sets the owner of the table object against which the article is filtered.

System_CAPS_pubpropertyFilterName

Gets or sets the name of the merge article join filter.

System_CAPS_pubpropertyFilterTypes

Gets or sets the type of merge join filter.

System_CAPS_pubpropertyJoinArticleName

Gets or sets the name of the parent article to which the filtered article is joined.

System_CAPS_pubpropertyJoinFilterClause

Gets or sets the clause that joins the child article, specified by ArticleName, to the parent article, specified by JoinArticleName, to filter the child article.

System_CAPS_pubpropertyJoinFilterId

Gets or sets the ID of the join filter or logical record relationship.

System_CAPS_pubpropertyJoinTableName

Gets or sets the name of the source table for the child article that is joined to the base table for the parent article.

System_CAPS_pubpropertyJoinTableOwner

Gets or sets the owner of the source table for the child article that is joined to the base table for the parent article.

System_CAPS_pubpropertyJoinUniqueKey

Gets or sets whether the join between the child article, specified by ArticleName, and the parent article, specified by JoinArticleName, is one-to-many, one-to-one, many-to-one, or many-to-many.

System_CAPS_pubpropertyUserData

Gets or sets a property that allows users to attach their own data to this object.

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

This namespace, class, or member is supported only in version 2.0 of the Microsoft .NET Framework.

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Legacy Code Example

			// 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();
			}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top

Community Additions

Show:
© 2015 Microsoft