Hi
is it possible on the following try-catch to execute a set of statements as a transaction using ADO NET Entity Data Model?
[ValidateInput(false)]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Customer c)
{
try
{
c.Created = DateTime.Now;
c.Active = true;
c.FullName = Request.Form["FirstName"];
db.AddToCustomer(c);
db.SaveChanges();
Log log = new Log();//another entity model object
log.Created = DateTime.Now;
log.Message =
string.Format(@"A new customer was created
with customerID {0}", c.CustomerID);
db.AddToLog(log);
db.SaveChanges();
return RedirectToAction("CreateSuccess", "Customer");
}
catch
{
return View();
}
}
Any thoughts would be very appreciated.