public void DisconnectedUpdate(TEntity e, object objValues)
 {
     using DataBaseContext _db = new DataBaseContext();
     _db.Attach(e);
     _db.Entry(e).CurrentValues.SetValues(objValues);
     _db.SaveChanges();
 }
Пример #2
0
 public void Delete(Comment entity)
 {
     if (_db.Entry(entity).State == EntityState.Detached)
     {
         _db.Attach(entity);
     }
     _db.Comments.Remove(entity);
 }
Пример #3
0
 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);
 }
Пример #5
0
 public void Delete(PostTextVisit entity)
 {
     if (_db.Entry(entity).State == EntityState.Detached)
     {
         _db.Attach(entity);
     }
     _db.PostTextVisits.Remove(entity);
 }
Пример #6
0
 public void Delete(UserInUser entity)
 {
     if (_db.Entry(entity).State == EntityState.Detached)
     {
         _db.Attach(entity);
     }
     _db.UserInUser.Remove(entity);
 }
Пример #7
0
 public void Delete(Offers entity)
 {
     if (_db.Entry(entity).State == EntityState.Detached)
     {
         _db.Attach(entity);
     }
     _db.Offers.Remove(entity);
 }
Пример #8
0
        /// <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);
        }
Пример #9
0
        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();
        }
Пример #10
0
 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()));
 }