我是使用Entity Framework for Postgresql事务的新手。我需要执行多个print("Congratulations! You swapped out a", box3, "for", str( randomPersuade2 ) + " Dollars. Enjoy!")
查询。
UPDATE
问题:
using (DbContextTransaction transaction = context.Database.BeginTransaction())
{
try
{
context.Database.ExecuteSqlCommand("Update table1 ....");
context.Database.ExecuteSqlCommand("Update table2 ....");
context.Database.ExecuteSqlCommand("Update table3 ....");
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
}
}
方法吗?