分布式事务
using (TransactionScope scope = new TransactionScope())
{
try
{
UserDAL dal = new UserDAL();
User item = new User
{
IDCard = "123123123",
Address = "IDCard",
EMail = "IDCard",
PassWord = "IDCard",
Power = "IDCard",
RealName = "IDCard",
Remarks = "IDCard",
UserName = Guid.NewGuid().ToString()
};
dal.Add(item);
Map mp = new Map { Name = "Name", Remarks = "Remarks" };
MapDAL mpdal = new MapDAL();
mpdal.Add(mp);
//throw new Exception("11");
User item1 = new User
{
IDCard = "123123123",
Address = "IDCard",
EMail = "IDCard",
PassWord = "IDCard",
Power = "IDCard",
RealName = "IDCard",
Remarks = "IDCard",
UserName = Guid.NewGuid().ToString()
};
dal.Add(item1);
scope.Complete();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}