AJ.*_*AJ. 4 c# subsonic msdtc transactions
要在Subsonic中使用事务构造(如下所示),MSDTC需要在Windows机器上运行.对?
using (TransactionScope ts = new TransactionScope())
{
using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
{
// update table 1
// update table 2
// ts.commit here
}
}
Run Code Online (Sandbox Code Playgroud)
MSDTC应该安装windows.如果不是,则可以使用以下命令进行安装:
msdtc -install
Run Code Online (Sandbox Code Playgroud)
您可以使用sc.exe配置MSDTC服务.将服务设置为自动启动并启动服务:
sc config msdtc start= auto
sc start msdtc
Run Code Online (Sandbox Code Playgroud)
请注意,您需要管理员权限才能执行上述操作.