public void DisconnectedUpdate(TEntity e, object objValues) { using DataBaseContext _db = new DataBaseContext(); _db.Attach(e); _db.Entry(e).CurrentValues.SetValues(objValues); _db.SaveChanges(); }
public void Delete(Comment entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.Comments.Remove(entity); }
public void Delete(likePost entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.likePosts.Remove(entity); }
public void Delete(BtnQuestion entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.BtnQuestion.Remove(entity); }
public void Delete(PostTextVisit entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.PostTextVisits.Remove(entity); }
public void Delete(UserInUser entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.UserInUser.Remove(entity); }
public void Delete(Offers entity) { if (_db.Entry(entity).State == EntityState.Detached) { _db.Attach(entity); } _db.Offers.Remove(entity); }
/// <summary> /// Handle: DeleteProduct. This method does not have any return parameter. /// </summary> protected override async Task Handle(DeleteProduct request, CancellationToken cancelToken) { if (_random.NextDouble() < 0.2) { throw new DeleteProductException($"Random error during deleting the product({request.Id})"); } Product product = new Product { Id = request.Id, IsDeleted = true }; EntityEntry <Product> entry = _dbContext.Attach(product); entry.Property(p => p.IsDeleted).IsModified = true; // Here you can have DbUpdateConcurrencyException exception, if the id is not exist. await _dbContext.SaveChangesAsync(cancelToken); }
public void randomize() { List <String> names = new List <string>() { "Greg", "Lewis", "Nick", "Neik", "David", "Onil" }; List <String> lastname = new List <string>() { "Hou", "Mod", "Ads", "Doid", "Adams", "Smith" }; Patient pt = new Patient(); pt.IdPatient = 1; pt.FirstName = names.PickRandom(); pt.LastName = lastname.PickRandom(); pt.BirthDate = DateTime.Now; dbContext.Attach(pt); dbContext.SaveChanges(); }
public bool Update(Comment Entity) { _context.Attach(Entity); return(Convert.ToBoolean(_context.SaveChanges())); }
public bool Update(GraphicDesigningPlan Entity) { _context.Attach(Entity); return(Convert.ToBoolean(_context.SaveChanges())); }