ReplicationObject.CachePropertyChanges Propriété

Définition

Obtient ou définit s'il faut mettre en cache des modifications effectuées sur les propriétés de réplication ou les appliquer immédiatement.

public:
 property bool CachePropertyChanges { bool get(); void set(bool value); };
public bool CachePropertyChanges { get; set; }
member this.CachePropertyChanges : bool with get, set
Public Property CachePropertyChanges As Boolean

Valeur de propriété

Valeur Boolean. Si la valeur est true, les modifications effectuées sur les propriété sont mises en cache. Si la valeur est false, les modifications effectuées sur les propriétés sont appliquées immédiatement.

Exemples

// Define the server, database, and publication names
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks2012";

TransPublication publication;

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

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

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

    // Explicitly enable caching of property changes on this object.
    publication.CachePropertyChanges = true;

    // If we can't get the properties for this publication, 
    // throw an application exception.
    if (publication.LoadProperties())
    {
        // Enable support for push subscriptions and disable support 
        // for pull subscriptions.
        if ((publication.Attributes & PublicationAttributes.AllowPull) != 0)
        {
            publication.Attributes ^= PublicationAttributes.AllowPull;
        }
        if ((publication.Attributes & PublicationAttributes.AllowPush) == 0)
        {
            publication.Attributes |= PublicationAttributes.AllowPush;
        }

        // Send changes to the server.
        publication.CommitPropertyChanges();
    }
    else
    {
        throw new ApplicationException(String.Format(
            "Settings could not be retrieved for the publication. " +
            "Ensure that the publication {0} exists on {1}.",
            publicationName, publisherName));
    }
}
catch (Exception ex)
{
    // Do error handling here.
    throw new ApplicationException(
        "The publication property could not be changed.", ex);
}
finally
{
    conn.Disconnect();
}
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2012"

Dim publication As TransPublication

' 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 publication.
    publication = New TransPublication()
    publication.ConnectionContext = conn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName

    ' Explicitly enable caching of property changes on this object.
    publication.CachePropertyChanges = True

    ' If we can't get the properties for this publication, 
    ' throw an application exception.
    If publication.LoadProperties() Then
        ' Enable support for push subscriptions and disable support 
        ' for pull subscriptions.
        If (publication.Attributes And PublicationAttributes.AllowPull) <> 0 Then
            publication.Attributes = publication.Attributes _
            Xor PublicationAttributes.AllowPull
        End If
        If (publication.Attributes And PublicationAttributes.AllowPush) = 0 Then
            publication.Attributes = publication.Attributes _
            Or PublicationAttributes.AllowPush
        End If

        ' Send changes to the server.
        publication.CommitPropertyChanges()
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication. " + _
         "Ensure that the publication {0} exists on {1}.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException( _
        "The publication property could not be changed.", ex)
Finally
    conn.Disconnect()
End Try

Remarques

Lorsque la valeur de CachePropertyChanges l’objet est false, les modifications de propriété sont immédiatement définies en fonction de la SqlExecutionModes propriété de l’objet ServerConnection . Lorsque la valeur est définie true, les modifications de propriété sont mises en cache jusqu’à ce qu’elles CommitPropertyChanges soient appelées. Quand CommitPropertyChanges elle est appelée, toutes les modifications de propriété après CachePropertyChanges ont été définies en fonction de la SqlExecutionModes propriété.

La mise en cache s’applique uniquement aux propriétés stockées dans Microsoft SQL Server.

La valeur par défaut de CachePropertyChanges est false.

S’applique à