how to add attribute from er model to sql via asp.net code example
Example 1: MVC company assignments
[HttpPost]
public ActionResult AddPerson(Person person)
{
if (ModelState.IsValid)
{
mDataContext.Persons.Add(person);
mDataContext.SaveChanges();
RedirectToAction("Index");
}
return View();
}
Example 2: MVC company assignments
[HttpGet]
public ActionResult AddPerson()
{
return View();
}
[HttpPost]
public ActionResult AddPerson(Person person)
{
mDataContext.Persons.Add(person);
mDataContext.SaveChanges();
return RedirectToAction("Index");
}