Categories
Development

ASP.NET :- Deleting records from two tables using single view

I want to delete data from 2 tables.

Here is the class .

[HttpPost]
        public ActionResult Delete(int employeeId)
        {
            int id = employeeId;
            MvcWebApp.DbModel.profile profile = dbContext.profiles.Find(employeeId);
            dbContext.profiles.Remove(profile);
            dbContext.SaveChanges();
            regi regi = dbContext.regis.Find(id);
            dbContext.regis.Remove(regi);
            dbContext.SaveChanges();
            return RedirectToAction("Index");
        }

Where employeeId is the Column name of child table and Id is column name of parent table .

Leave a Reply

Your email address will not be published. Required fields are marked *