Share via


Clase MergePartition

Represents information about a Subscriber's partition for a merge publication with a parameterized row filter.

Jerarquía de herencia

System. . :: . .Object
  Microsoft.SqlServer.Replication..::..MergePartition

Espacio de nombres:  Microsoft.SqlServer.Replication
Ensamblado:  Microsoft.SqlServer.Rmo (en Microsoft.SqlServer.Rmo.dll)

Sintaxis

'Declaración
Public NotInheritable Class MergePartition
'Uso
Dim instance As MergePartition
public sealed class MergePartition
public ref class MergePartition sealed
[<SealedAttribute>]
type MergePartition =  class end
public final class MergePartition

El tipo MergePartition expone los siguientes miembros.

Constructores

  Nombre Descripción
Método público MergePartition Creates a new instance of the MergePartition class.

Arriba

Propiedades

  Nombre Descripción
Propiedad pública CurrentSnapshotDateTime Gets or sets the date and time when the data snapshot of the partition was generated.
Propiedad pública DynamicFilterHostName Gets or sets the value supplied to the HOST_NAME (Transact-SQL) function to generate the data snapshot, when the parameterized row filter is defined using this function.
Propiedad pública DynamicFilterLogin Gets or sets the value supplied to the SUSER_SNAME (Transact-SQL) function to generate the data snapshot, when the parameterized row filter is defined using this function.
Propiedad pública DynamicSnapshotJobId Gets or sets the Microsoft SQL Server Agent job ID, in hexadecimal format, which generates the filtered snapshot for the Subscriber.
Propiedad pública DynamicSnapshotLocation Gets or sets the operating system folder used to store the filtered snapshot generated for the partition.
Propiedad pública PartitionId Gets or sets the ID value that uniquely identifies the partition.
Propiedad pública UserData Gets or sets an object that allows you to attach custom data to this instance of MergePartition.

Arriba

Métodos

  Nombre Descripción
Método público Equals (Se hereda de Object.)
Método protegido Finalize (Se hereda de Object.)
Método público GetHashCode (Se hereda de Object.)
Método público GetType (Se hereda de Object.)
Método protegido MemberwiseClone (Se hereda de Object.)
Método público ToString (Se hereda de Object.)

Arriba

Comentarios

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

Thread Safety

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.

Ejemplos

            // Define the server, database, and publication names
            string publisherName = publisherInstance;
            string publicationName = "AdvWorksSalesOrdersMerge";
            string publicationDbName = "AdventureWorks2008R2";
            string distributorName = publisherInstance;

            MergePublication publication;
            MergePartition partition;
            MergeDynamicSnapshotJob snapshotAgentJob;
            ReplicationAgentSchedule schedule;
            
            // Create a connection to the Publisher.
            ServerConnection publisherConn = new ServerConnection(publisherName);

            // Create a connection to the Distributor to start the Snapshot Agent.
            ServerConnection distributorConn = new ServerConnection(distributorName);

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

                // Set the required properties for the publication.
                publication = new MergePublication();
                publication.ConnectionContext = publisherConn;
                publication.Name = publicationName;
                publication.DatabaseName = publicationDbName;


                // If we can't get the properties for this merge publication, 
                // then throw an application exception.
                if (publication.LoadProperties() || publication.SnapshotAvailable)
                {
                    // Set a weekly schedule for the filtered data snapshot.
                    schedule = new ReplicationAgentSchedule();
                    schedule.FrequencyType = ScheduleFrequencyType.Weekly;
                    schedule.FrequencyRecurrenceFactor = 1;
                    schedule.FrequencyInterval = Convert.ToInt32(0x001);

                    // Set the value of Hostname that defines the data partition. 
                    partition = new MergePartition();
                    partition.DynamicFilterHostName = hostname;
                    snapshotAgentJob = new MergeDynamicSnapshotJob();
                    snapshotAgentJob.DynamicFilterHostName = hostname;

                    // Create the partition for the publication with the defined schedule.
                    publication.AddMergePartition(partition);
                    publication.AddMergeDynamicSnapshotJob(snapshotAgentJob, schedule);
                }
                else
                {
                    throw new ApplicationException(String.Format(
                        "Settings could not be retrieved for the publication, " +
                        " or the initial snapshot has not been generated. " +
                        "Ensure that the publication {0} exists on {1} and " +
                        "that the Snapshot Agent has run successfully.",
                        publicationName, publisherName));
                }
            }
            catch (Exception ex)
            {
                // Do error handling here.
                throw new ApplicationException(string.Format(
                    "The partition for '{0}' in the {1} publication could not be created.",
                    hostname, publicationName), ex);
            }
            finally
            {
                publisherConn.Disconnect();
                if (distributorConn.IsOpen) distributorConn.Disconnect();
            }
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim distributorName As String = publisherInstance

Dim publication As MergePublication
Dim partition As MergePartition
Dim snapshotAgentJob As MergeDynamicSnapshotJob
Dim schedule As ReplicationAgentSchedule

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

' Create a connection to the Distributor to start the Snapshot Agent.
Dim distributorConn As ServerConnection = New ServerConnection(distributorName)

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

    ' Set the required properties for the publication.
    publication = New MergePublication()
    publication.ConnectionContext = publisherConn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName


    ' If we can't get the properties for this merge publication, 
    ' then throw an application exception.
    If (publication.LoadProperties() Or publication.SnapshotAvailable) Then
        ' Set a weekly schedule for the filtered data snapshot.
        schedule = New ReplicationAgentSchedule()
        schedule.FrequencyType = ScheduleFrequencyType.Weekly
        schedule.FrequencyRecurrenceFactor = 1
        schedule.FrequencyInterval = Convert.ToInt32("0x001", 16)

        ' Set the value of Hostname that defines the data partition. 
        partition = New MergePartition()
        partition.DynamicFilterHostName = hostname
        snapshotAgentJob = New MergeDynamicSnapshotJob()
        snapshotAgentJob.DynamicFilterHostName = hostname

        ' Create the partition for the publication with the defined schedule.
        publication.AddMergePartition(partition)
        publication.AddMergeDynamicSnapshotJob(snapshotAgentJob, schedule)
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication, " + _
         " or the initial snapshot has not been generated. " + _
         "Ensure that the publication {0} exists on {1} and " + _
         "that the Snapshot Agent has run successfully.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException(String.Format( _
     "The partition for '{0}' in the {1} publication could not be created.", _
     hostname, publicationName), ex)
Finally
    publisherConn.Disconnect()
    If distributorConn.IsOpen Then
        distributorConn.Disconnect()
    End If
End Try

Seguridad para subprocesos

Cualquier miembro público static (Shared en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.