0
我需要使用嵌套事務範圍執行一些動作:嵌套的TransactionScope
1)插入地址
2),之後插入的ContactInfo
3)之後插入的UserInfo
//one class
using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required))
{
user.ContactInfo = BLContactInfo.Add(user.ContactInfo);
BEUser newUser = DLSecurity.CreateUser(user);
transaction.Complete();
//.......
}
//two class
using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required))
{
contactInfo.Address = BLAddress.Add(contactInfo.Address);
BEContactInfo newContactInfo = DLContactInfo.Add(contactInfo);
transaction.Complete();
return newContactInfo;
}
我不知道:這種方式好嗎?我可以避免使用嵌套事務嗎?