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

Raw Insert query in EF8 or Entity Framwork 8

          public async Task<object> InsertRack(Rack RackInsert)         {             try             {                 sql = " i...