使用System.Transaction
,您可以嵌套TransactionScope
,例如:
using (var tran1 = new TransactionScope())
{
// modify context
using (var tran2 = new TransactionScope())
{
// modify context
tran2.Complete();
}
tran1.Complete();
}
如何使用DbContext.Database.BeginTransaction()
在Entity Framework Core 2.1中模拟这种行为?