コード例 #1
0
ファイル: LighEntityObject.cs プロジェクト: zhangbo27/fireasy
        private void RegisterProperty(Type entityType, PropertyInfo property)
        {
            //关联属性,即关联实体或子实体集属性
            if (typeof(IEntity).IsAssignableFrom(property.PropertyType) ||
                typeof(IEntitySet).IsAssignableFrom(property.PropertyType))
            {
                var mapping = property.GetCustomAttributes <PropertyMappingAttribute>().FirstOrDefault();
                var options = mapping != null && mapping.GetFlag(PropertyMappingAttribute.SetMark.LoadBehavior) ?
                              new RelationOptions(mapping.LoadBehavior) : null;

                PropertyUnity.RegisterSupposedProperty(property.Name, property.PropertyType, entityType, options: options);
            }
            else
            {
                var gp = new GeneralProperty()
                {
                    Name       = property.Name,
                    Type       = property.PropertyType,
                    EntityType = entityType,
                    Info       = new PropertyMapInfo {
                        ReflectionInfo = property, FieldName = property.Name
                    }
                };

                var mapping = property.GetCustomAttributes <PropertyMappingAttribute>().FirstOrDefault();
                if (mapping != null)
                {
                    InitMapInfo(mapping, gp.Info);
                }

                PropertyUnity.RegisterProperty(entityType, gp);
            }
        }