Article.Type Property
Assembly: Microsoft.SqlServer.Rmo (in microsoft.sqlserver.rmo.dll)
/** @property */ public ArticleOptions get_Type () /** @property */ public void set_Type (ArticleOptions value)
public function get Type () : ArticleOptions public function set Type (value : ArticleOptions)
Property Value
An ArticleOptions enumeration value that specifies the type of article.| Exception type | Condition |
|---|---|
| ApplicationException |
When you set Type to an unsupported ArticleOptions value or when you set Type for an existing article. |
The Type property defaults to LogBased for a transactional or snapshot publication and TableBased for a merge publication.
The Type property must be set before calling Create to create the article on the server. Once the article exists on the server, this property cannot be set.
The Type property can be retrieved by members of the sysadmin fixed server role at the Publisher and at the Subscriber (for republishing Subscribers). It can also be retrieved by members of the db_owner fixed database role on the publication database and by users who are members of the PAL. For a MergeArticle object, this property can also be retrieved by members of the replmonitor fixed database role on the Distributor.
The Type property can be set by members of the sysadmin fixed server role at the Publisher. It can also be set by members of the db_owner fixed database role on the publication database.
Retrieving Type is equivalent to executing sp_helparticle (Transact-SQL) for transactional or snapshot replication or executing sp_helpmergearticle (Transact-SQL) for merge replication.
Setting Type is equivalent to executing sp_addarticle (Transact-SQL) for transactional or snapshot replication or executing sp_addmergearticle (Transact-SQL) for merge replication.
The Type property is available with SQL Server 2005, SQL Server 2000, and SQL Server 7.0..
This namespace, class, or member is supported only in the .NET Framework 2.0.
// Define the Publisher and publication names. string publisherName = publisherInstance; string publicationName = "AdvWorksSalesOrdersMerge"; string publicationDbName = "AdventureWorks"; // 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(); }