using (TransactionScope scope = new TransactionScope())
{
using (var objContext = GetContext())
{
objContext.SMS.Add(model);
foreach (Product_SMS m in list)
{
//m.SmsID = model.ID;这里获取不到ID
objContext.Product_SMS.Add(m);
}
objContext.SaveChanges();
}
scope.Complete();
}
using (TransactionScope scope = new TransactionScope())
{
using (var objContext = GetContext())
{
objContext.SMS.Add(model);
objContext.SaveChanges();
foreach (Product_SMS m in list)
{
//m.SmsID = model.ID;这里获取不到ID
objContext.Product_SMS.Add(m);
}
objContext.SaveChanges();
}
scope.Complete();
}