public void Update(UserDetail userDetail) { using (UserEntities context = DbContextFactory.Create()) { context.Entry(userDetail).State = EntityState.Modified; context.SaveChanges(); } }
public void Insert(UserDetail userDetail) { using (UserEntities context = DbContextFactory.Create()) { context.Set <UserDetail>().Add(userDetail); context.Entry(userDetail).State = EntityState.Added; context.SaveChanges(); } }
public void DeleteByPK(int id) { using (UserEntities context = DbContextFactory.Create()) { var userDetail = context.UserDetails.FirstOrDefault(x => x.UserId == id); if (userDetail == null) { return; } context.Entry(userDetail).State = EntityState.Deleted; context.SaveChanges(); } }