在子事务范围中查找父事务范围的 TransactionScopeOption
在父事务范围中,我的 TransactionScopeOption 为必需的。
稍后在内部事务范围中,我需要检查父事务范围的 TransactionScopeOption。
这怎么可能..
例子
Parent : using (TransactionScope transactionScopeParent = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
....
method()
}
method()
{
here i need to check the TransactionScopeOption of this transaction scope's parent one and then set this transaction scope to be having the same TransactionScopeOption.
using (TransactionScope transactionScopeChild = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
}
是可能的。
In a parent transaction scope, i have the TransactionScopeOption of Required.
Later on in a inner transaction scope, i need to check the TransactionScopeOption of the parent transaction scope.
How is this possible..
Example
Parent : using (TransactionScope transactionScopeParent = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
....
method()
}
method()
{
here i need to check the TransactionScopeOption of this transaction scope's parent one and then set this transaction scope to be having the same TransactionScopeOption.
using (TransactionScope transactionScopeChild = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
}
is this possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是不需要的。
如果“父级”
TransactionScope
为必需
,则嵌套的事务范围将已注册到事务中。如果不是,嵌套的将不会自动成为“必需”。
唯一的例外是,如果您将嵌套的
TransactionScope
显式设置为RequiresNew
,则新事务将启动。This is not needed.
If the "parent"
TransactionScope
isRequired
, the nested one will be enrolled it the transactions already.If it isn't, the nested one will not automatically become "required".
The only exception is if you explicitly set the nested
TransactionScope
toRequiresNew
, when a new transaction will start.从您对@Oded答案的评论来看,您似乎希望
System.Transactions.Transaction
s要获得该行为,您只需附加
到您的 MySQL 连接字符串:
Judging from your comments to @Oded's answer, you seem to want
System.Transactions.Transaction
sTo get that behavior, you just need to append
to your MySQL connection string: