在父事务范围中,我有TransactionScopeOption of Required。在子事务处理范围中查找父事务范围的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))
}
这是可能的。
请注意,我的用法是,内部事务将使其TransactionScope默认为'suppress',但是当存在父事务处理范围时,则需要将此“suppress”更改为与父级内联TransactionScope的。请确认 – Saravanan 2011-06-02 05:51:33
@saravanan - 如果您禁止内部交易,它将不参与交易。也许你应该创建你的函数的两个版本 - 一个抑制交易,一个不行。 – Oded 2011-06-02 05:56:15
我实际上必须为MySQL和SQL事务使用此功能。在SQL的情况下,我将允许子交易参与父交易。在MySQL的情况下,由于MySQL不支持分布式事务,所以它将处于被压缩的事务中。 – Saravanan 2011-06-03 04:02:04