CreateApplicationTransaction 方法

创建一个已提交读的事务,通过该事务将变更应用于数据库。

命名空间:  Microsoft.Synchronization.Data
程序集:  Microsoft.Synchronization.Data(在 Microsoft.Synchronization.Data.dll 中)

语法

声明
Protected Overridable Function CreateApplicationTransaction As IDbTransaction
用法
Dim returnValue As IDbTransaction

returnValue = Me.CreateApplicationTransaction()
protected virtual IDbTransaction CreateApplicationTransaction()
protected:
virtual IDbTransaction^ CreateApplicationTransaction()
abstract CreateApplicationTransaction : unit -> IDbTransaction 
override CreateApplicationTransaction : unit -> IDbTransaction 
protected function CreateApplicationTransaction() : IDbTransaction

返回值

类型:System.Data. . :: . .IDbTransaction
该事务用于将变更应用于数据库。

示例

下面的代码示例重写此方法并设置一个在 Oracle 数据库中启用快照的选项。

protected override IDbTransaction CreateApplicationTransaction()
        {
            OracleTransaction trans = (OracleTransaction)this.Connection.BeginTransaction();
            new OracleCommand("set transaction read only", (OracleConnection)this.Connection, trans).ExecuteNonQuery();
            return trans;        
        }
Protected Overloads Overrides Function CreateApplicationTransaction() As IDbTransaction
    Dim trans As OracleTransaction = DirectCast(Me.Connection.BeginTransaction(), OracleTransaction)
    New OracleCommand("set transaction read only", DirectCast(Me.Connection, OracleConnection), trans).ExecuteNonQuery() 
    Return trans
End Function

请参阅

参考

RelationalSyncProvider类

RelationalSyncProvider 成员

Microsoft.Synchronization.Data 命名空间