public override PropertyValue GetValue(IEntity entity, IProperty property)
        {
            var enumProperty = property.As <EnumProperty>();
            var value        = entity.InternalGetValue(enumProperty.Reference);

            return(value.IsNullOrEmpty() ? null : PropertyValueHelper.NewValue(((Enum)value).GetDescription()));
        }
        public override PropertyValue GetValue(IEntity entity, IProperty property)
        {
            var entityProperty = property.As <EntitySetProperty>();
            var instanceName   = GetInstanceName(entity, entityProperty.RelationType);
            var environment    = GetEnvironment(entity);

            using (var context = new InternalContext(instanceName))
            {
                context.Environment  = environment;
                context.InstanceName = instanceName;

                var    provider   = context.CreateRepositoryProvider(entityProperty.RelationType);
                var    expression = BuidRelationExpression(entity, entityProperty);
                object result     = null;
                if (expression != null)
                {
                    result = Execute(provider.Queryable, expression);
                    var querySetType = typeof(EntitySet <>).MakeGenericType(entityProperty.RelationType);
                    var list         = querySetType.New(new[] { result });

                    //设置实体集所属的实体Owner
                    list.As <IEntityRelation>(e => e.Owner = new EntityOwner(entity, property));

                    return(PropertyValueHelper.NewValue(list));
                }

                return(PropertyValueHelper.NewValue(result));
            }
        }
        public override PropertyValue GetValue(IEntity entity, IProperty property)
        {
            var referenceProperty = property.As <ReferenceProperty>();
            var instanceName      = GetInstanceName(entity, referenceProperty.RelationType);
            var environment       = GetEnvironment(entity);

            using (var context = new InternalContext(instanceName))
            {
                context.As <IEntityPersistentEnvironment>(s => s.Environment        = environment);
                context.As <IEntityPersistentInstanceContainer>(s => s.InstanceName = instanceName);

                var    provider   = context.CreateRepositoryProvider(referenceProperty.RelationType);
                var    expression = BuidRelationExpression(entity, referenceProperty);
                object result     = null;
                if (expression != null)
                {
                    result = Execute(provider.Queryable, expression);
                }

                return(PropertyValueHelper.NewValue(result));
            }
        }