Sunday, June 2, 2019

Linq Delete with EntityState

1.
public ActionResult Delete(int id)
{
    using (var cont = new db_context())
    {
        var emp = new Employee()
        {
            emp_id = id
        };
        cont.Entry(emp).State = System.Data.Entity.EntityState.Deleted;
        cont.SaveChanges();
    }
    return RedirectToAction("index");
}

No comments:

Post a Comment

When web application with sql server connection using sql client, working in visual studio but not working in localhost as in iis

Error:  The EXECUTE permission was denied on the object 'StoredProcedureTest1', database 'testDb1', schema 'dbo'.  C...