Exemplo n.º 1
0
        private void UpdateMultiReference(IUnitOfWork unitOfWork, BaseEntity entity, PropertyInfo targetProperty, List <Guid> referencedIds, ICollection <U> referencedEntities)
        {
            GenericDao      genericDao = new GenericDao(unitOfWork);
            IList           currentReferencedEntities = CollectReferencedEntities(unitOfWork, targetProperty, referencedIds);
            ICollection <U> targetPropertyValue       = (ICollection <U>)targetProperty.GetValue(entity);

            targetPropertyValue.Clear();
            genericDao.Attach(entity.GetType(), entity);
            foreach (U currentReferencedEntity in currentReferencedEntities)
            {
                genericDao.Attach <U>(currentReferencedEntity);
            }
            targetPropertyValue.Clear();
            foreach (U currentReferencedEntity in currentReferencedEntities)
            {
                targetPropertyValue.Add(currentReferencedEntity);
            }
        }