ReplicationObject.CachePropertyChanges Property
Gets or sets whether to cache changes made to the replication properties or to apply them immediately.
Пространство имен: Microsoft.SqlServer.Replication
Сборка: Microsoft.SqlServer.Rmo (in microsoft.sqlserver.rmo.dll)
Синтаксис
'Декларация
Public Property CachePropertyChanges As Boolean
public bool CachePropertyChanges { get; set; }
public:
property bool CachePropertyChanges {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_CachePropertyChanges ()
/** @property */
public void set_CachePropertyChanges (boolean value)
public function get CachePropertyChanges () : boolean
public function set CachePropertyChanges (value : boolean)
Значение свойства
A Boolean value. If true, the property changes are cached. If false, the property changes are applied immediately.
Замечания
When the value of CachePropertyChanges is false, property changes are immediately set according to the SqlExecutionModes property of the ServerConnection object. When the value is set to true, property changes will be cached until CommitPropertyChanges is called. When CommitPropertyChanges is called, all property changes after CachePropertyChanges are set according to the SqlExecutionModes property.
Caching only applies to properties stored in Microsoft SQL Server.
The default value of CachePropertyChanges is false.
This property is available with SQL Server 7.0, SQL Server 2000, and SQL Server 2005.
This namespace, class, or member is supported only in version 2.0 of the .NET Framework.
Пример
// Define the server, database, and publication names
string publisherName = publisherInstance;
string publicationName = "AdvWorksProductTran";
string publicationDbName = "AdventureWorks";
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 = "AdventureWorks"
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
Синхронизация потоков
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Платформы
Платформы разработки
Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.
Целевые платформы
Список поддерживаемых платформ см. в разделе Hardware and Software Requirements for Installing SQL Server 2005.
См. также
Справочник
ReplicationObject Class
ReplicationObject Members
Microsoft.SqlServer.Replication Namespace