public void Create() { PullentiEntitiesCreator pullentiEntitiesCreator = new PullentiEntitiesCreator(); List <Article> articles = articleDao.SelectAll(); List <Entity> entities = entitiesDao.SelectAll(); List <Entity> newEntities = pullentiEntitiesCreator.CreateEntities(entities, articles); List <Entity> entitiesToUpdate = null; foreach (var item in newEntities) { var oldEntity = entities.Find(c => c.Value.Equals(item.Value)); if (oldEntity != null) { oldEntity.Properties = item.Properties; entitiesToUpdate.Add(oldEntity); } } foreach (var item in entitiesToUpdate) { var entityToRemove = newEntities.Find(m => m.Value.Equals(item.Value)); newEntities.Remove(entityToRemove); } entitiesDao.SaveAll(newEntities); entitiesDao.UpdateAll(entitiesToUpdate); }