ReplicationObject.CachePropertyChanges プロパティ
レプリケーション プロパティに加えられた変更をキャッシュするか、またはすぐに適用するかを取得します。値の設定も可能です。
名前空間: Microsoft.SqlServer.Replication
アセンブリ: Microsoft.SqlServer.Rmo (Microsoft.SqlServer.Rmo.dll)
構文
'宣言
Public Property CachePropertyChanges As Boolean
Get
Set
'使用
Dim instance As ReplicationObject
Dim value As Boolean
value = instance.CachePropertyChanges
instance.CachePropertyChanges = value
public bool CachePropertyChanges { get; set; }
public:
property bool CachePropertyChanges {
bool get ();
void set (bool value);
}
member CachePropertyChanges : bool with get, set
function get CachePropertyChanges () : boolean
function set CachePropertyChanges (value : boolean)
プロパティ値
型: System.Boolean
Boolean 値です。true の場合、プロパティの変更はキャッシュされます。false の場合、プロパティの変更はすぐに適用されます。
説明
CachePropertyChanges の値が false の場合、プロパティの変更は、ServerConnection オブジェクトの SqlExecutionModes プロパティに従って、すぐに設定されます。 値を true に設定すると、プロパティの変更は、CommitPropertyChanges が呼び出されるまでキャッシュされます。 CommitPropertyChanges が呼び出されると、CachePropertyChanges の後で加えられたすべてのプロパティ変更が、SqlExecutionModes プロパティに従って設定されます。
キャッシュは、Microsoft SQL Server に格納されたプロパティにのみ適用されます。
CachePropertyChanges の既定値は false です。
使用例
// 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