Exemple #1
0
        private void UpdateRelations(IEntity entity)
        {
            var entityEx = entity.As <IEntityStatefulExtension>();

            if (entityEx == null)
            {
                return;
            }

            var relProperties = PropertyUnity.GetRelatedProperties(entity.EntityType);

            foreach (var property in relProperties)
            {
                var relationPro = property as RelationProperty;
                var value       = entityEx.GetDirectValue(property);
                if (value == null)
                {
                    continue;
                }

                switch (relationPro.RelationPropertyType)
                {
                case RelationPropertyType.EntitySet:
                    var list = PropertyValueHelper.GetValue <IEnumerable>(value);
                    EntityUtility.AttachPrimaryKeyValues(entity, relationPro, list);
                    Save(list);
                    break;

                case RelationPropertyType.Entity:
                    SaveRelationEntity(PropertyValueHelper.GetValue <IEntity>(value));
                    break;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 获取指定属性的值。
 /// </summary>
 /// <typeparam name="T">值的类型。</typeparam>
 /// <param name="property">实体属性。</param>
 /// <returns></returns>
 public virtual T GetValue <T>(IProperty property)
 {
     return(PropertyValueHelper.GetValue <T>(GetValue(property)));
 }