public EntityDynAttribute[] GetCustomAttributes(Type attributeType, bool inherit)
        {
            if (inherit == false)
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                foreach (EntityDynAttribute attr in _attributes)
                {
                    if (attributeType.IsAssignableFrom(attr.GetType()))
                    {
                        attrs.Add(attr);
                    }
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                foreach (EntityDynAttribute attr in _attributes)
                {
                    if (attributeType.IsAssignableFrom(attr.GetType()))
                    {
                        attrs.Add(attr);
                    }
                }

                DynEntityType parentType = DynEntityTypeManager.GetEntityType(this.EntityType.BaseEntityName);
                while (parentType != null)
                {
                    if (parentType.ContainsProperty(_name))
                    {
                        foreach (EntityDynAttribute attr in parentType.GetProperty(_name).Attributes)
                        {
                            if (attributeType.IsAssignableFrom(attr.GetType()))
                            {
                                attrs.Add(attr);
                            }
                        }
                    }

                    parentType = DynEntityTypeManager.GetEntityType(parentType.BaseEntityName);
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Gets the modified properties of this entity, not including query properties and properties of base entity's.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns>The modified properties</returns>
        public Dictionary <string, object> GetModifiedProperties(DynEntityType entityType)
        {
            EntityConfiguration ec = MetaDataManager.GetEntityConfiguration(entityType.FullName);

            if (string.IsNullOrEmpty(entityType.BaseEntityName))
            {
                return(changedProperties);
            }

            List <string> toRemoveItems = new List <string>();

            foreach (string item in changedProperties.Keys)
            {
                PropertyConfiguration pc = ec.GetPropertyConfiguration(item);
                if (pc == null || pc.IsInherited || pc.IsPrimaryKey)
                {
                    toRemoveItems.Add(item);
                }
            }
            Dictionary <string, object> retProperties = new Dictionary <string, object>();

            foreach (string item in changedProperties.Keys)
            {
                if (!toRemoveItems.Contains(item))
                {
                    retProperties.Add(item, changedProperties[item]);
                }
            }
            return(retProperties);
        }
Пример #3
0
        private static string GetOutputNamespace(string typeName)
        {
            string outNs = "Entities";

            DynEntityType entityType = DynEntityTypeManager.GetEntityType(typeName);

            //OutputNamespaceDynAttribute outNsAttr = DynCodeGenHelper.GetEntityAttribute<OutputNamespaceDynAttribute>(typeName);
            //if (outNsAttr != null)
            //{
            //    return outNsAttr.Namespace;
            //}
            //else
            //{
            //    return outNs;
            //}

            if (entityType != null)
            {
                return(entityType.Namespace);
            }
            else
            {
                return(outNs);
            }
        }
Пример #4
0
        public bool IsAssignableFrom(DynEntityType entityType)
        {
            if (entityType.Name == this.Name)
            {
                return(true);
            }
            else
            {
                DynEntityType parentType = this.BaseEntityType;

                while (parentType != null)
                {
                    if (parentType.Name == this.Name)
                    {
                        return(true);
                    }
                    else
                    {
                        parentType = parentType.BaseEntityType;
                    }
                }
            }

            return(false);
        }
 public static void AddEntityType(DynEntityType obj)
 {
     if (obj != null)
     {
         if (_entitytypes.Contains(obj) == false)
         {
             _entitytypes.Add(obj);
         }
     }
 }
Пример #6
0
        /// <summary>
        /// Convert an entity array to a data table.
        /// </summary>
        /// <param name="objs">The entity array.</param>
        /// <returns>The data table.</returns>
        public static DataTable EntityArrayToDataTable(DynEntityType entityType, DynEntity[] objs)
        {
            EntityConfiguration ec;

            if (objs != null && objs.Length > 0)
            {
                ec = MetaDataManager.GetEntityConfiguration(objs[0].EntityType.FullName);
            }
            else
            {
                ec = MetaDataManager.GetEntityConfiguration(entityType.FullName);
            }

            DataTable table = new DataTable(ec.Name);

            foreach (PropertyConfiguration pc in ec.Properties)
            {
                if ((!pc.IsQueryProperty) || (pc.QueryType == "FkReverseQuery"))
                {
                    DataColumn column = new DataColumn(pc.QueryType == "FkReverseQuery" ? pc.MappingName : pc.Name, Util.GetType(pc.PropertyMappingColumnType.Replace("System.Nullable`1[", "").Replace("]", "")));
                    table.Columns.Add(column);
                }
            }

            if (objs != null && objs.Length > 0)
            {
                for (int i = 0; i < objs.Length; i++)
                {
                    object[] values = DynEntity.GetPropertyValues(objs[i], DynEntity.GetPropertyMappingColumnNames(MetaDataManager.GetEntityConfiguration(objs[0].EntityType.Name)));
                    DataRow  row    = table.NewRow();

                    int j = 0;
                    foreach (PropertyConfiguration pc in ec.Properties)
                    {
                        if ((!pc.IsQueryProperty) || (pc.QueryType == "FkReverseQuery"))
                        {
                            object value = (values[j] == null ? DBNull.Value : values[j]);
                            //if (pc.IsCompoundUnit)
                            //{
                            //    value = SerializationManager.Serialize(value);
                            //}
                            row[j] = value;
                        }

                        j++;
                    }

                    table.Rows.Add(row);
                }
            }
            table.AcceptChanges();
            return(table);
        }
        public static PropertyItem P(string typeName, string propertyName)
        {
            DynEntityType            entityType = DynEntityTypeManager.GetEntityTypeMandatory(typeName);
            DynPropertyConfiguration property   = entityType.GetProperty(propertyName);

            if (property.IsInherited)
            {
                DynEntityType baseEntityType = DynEntityTypeManager.GetEntityTypeMandatory(property.InheritEntityMappingName);
                return(new PropertyItem(propertyName, baseEntityType.FullName));
            }
            else
            {
                return(new PropertyItem(propertyName, entityType.FullName));
            }
        }
Пример #8
0
        // 原来的方法名:GetInterface()
        public DynEntityType[] GetAllBaseEntityTypes()
        {
            List <DynEntityType> lstEntityTypes = new List <DynEntityType>();

            DynEntityType parentType = this.BaseEntityType;

            while (parentType != null)
            {
                lstEntityTypes.Add(parentType);

                parentType = parentType.BaseEntityType;
            }

            return(lstEntityTypes.ToArray());
        }
Пример #9
0
        /// <summary>
        /// 基于实体类型构造对象
        /// </summary>
        /// <param name="entityType"></param>
        public DynEntity(string typeName)
        {
            // 这里应该是从数据库中加载
            DynEntityType entityType = DynEntityTypeManager.GetEntityType(typeName);

            if (entityType == null)
            {
                throw new ApplicationException("实体类型不能为空");
            }

            this.PropertyChanged += new PropertyChangedHandler(Entity_PropertyChanged);
            isAttached            = false;

            _entityType = entityType;

            int normalCnt = 0;
            int queryCnt  = 0;

            foreach (DynPropertyConfiguration entityProperty in _entityType.GetProperties())
            {
                if (entityProperty.IsQueryProperty == true)
                {
                    if (entityProperty.IsArray)
                    {
                        _queryPropertyNameIdMap.Add("_" + entityProperty.Name, queryCnt++);
                        _queryPropertyValues.Add(null);
                    }
                    else
                    {
                        QueryDynAttribute qa        = entityProperty.GetPropertyQueryAttribute();
                        DynQueryDescriber describer = new DynQueryDescriber(qa, entityProperty, entityProperty.PropertyOriginalEntityType, _entityType.Name);

                        _normalPropertyNameIdMap.Add("_" + entityProperty.Name + "_" + describer.RelatedForeignKey, normalCnt++);
                        _fkPropertyNameNormalPropertyNameMap.Add("_" + entityProperty.Name + "_" + describer.RelatedForeignKey, entityProperty.Name);
                        _normalPropertyValues.Add(null);

                        _queryPropertyNameIdMap.Add("_" + entityProperty.Name, queryCnt++);
                        _queryPropertyValues.Add(null);
                    }
                }
                else
                {
                    _normalPropertyNameIdMap.Add("_" + entityProperty.Name, normalCnt++);
                    _normalPropertyValues.Add(null);
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Data table to entity array.
        /// </summary>
        /// <param name="dt">The dt.</param>
        /// <param name="setEntitiesAsModified">if set to <c>true</c> set entities as modified.</param>
        /// <returns></returns>
        public static DynEntity[] DataTableToEntityArray(DynEntityType entityType, DataTable dt, bool setEntitiesAsModified)
        {
            if (dt == null)
            {
                return(null);
            }

            DynEntity[] objs = new DynEntity[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                objs[i] = new DynEntity(entityType);
                objs[i].SetPropertyValues(dt.Rows[i]);
                if (setEntitiesAsModified)
                {
                    objs[i].Attach();
                    objs[i].SetAllPropertiesAsModified();
                }
            }

            return(objs);
        }
Пример #11
0
        public EntityDynAttribute[] GetCustomAttributes(bool inherit)
        {
            if (inherit == false)
            {
                if (_attributes.Count > 0)
                {
                    return(_attributes.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                attrs.AddRange(_attributes);

                DynEntityType parentType = this.BaseEntityType;
                while (parentType != null)
                {
                    attrs.AddRange(parentType.Attributes);

                    parentType = parentType.BaseEntityType;
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
        public EntityDynAttribute[] GetCustomAttributes(bool inherit)
        {
            if (inherit == false)
            {
                if (_attributes.Count > 0)
                {
                    return(_attributes.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                attrs.AddRange(_attributes);

                DynEntityType parentType = DynEntityTypeManager.GetEntityType(this.EntityType.BaseEntityName);
                while (parentType != null)
                {
                    attrs.AddRange(parentType.GetProperty(_name).Attributes);

                    parentType = DynEntityTypeManager.GetEntityType(parentType.BaseEntityName);
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
Пример #13
0
        /// <summary>
        /// new an EntityType from an EntityConfiguration
        /// </summary>
        /// <param name="ec"></param>
        /// <returns></returns>
        public static DynEntityType EntityConfiguration2EntityType(EntityConfiguration ec)
        {
            string nameSpace, typeName, baseName;

            Util.SplitFullName(ec.Name, out nameSpace, out typeName);

            DynEntityType et;

            if (string.IsNullOrEmpty(ec.BaseEntity))
            {
                et = new DynEntityType(typeName);
            }
            else
            {
                Util.SplitFullName(ec.BaseEntity, out nameSpace, out baseName);
                et = new DynEntityType(typeName, baseName);
            }
            et.AdditionalSqlScript = ec.AdditionalSqlScript;
            et.BaseEntityName      = ec.BaseEntity;
            et.BatchSize           = ec.BatchSize;
            et.Comment             = ec.Comment;
            et.CustomData          = ec.CustomData;
            et.IsAutoPreLoad       = ec.IsAutoPreLoad;
            et.IsBatchUpdate       = ec.IsBatchUpdate;
            et.IsReadOnly          = ec.IsReadOnly;
            et.IsRelation          = ec.IsRelation;
            et.MappingName         = ec.MappingName;
            et.Namespace           = nameSpace;
            et.Name     = typeName;
            et.ViewName = ec.ViewName;


            if (string.IsNullOrEmpty(nameSpace) == false)
            {
                et.Attributes.Add(new OutputNamespaceDynAttribute(nameSpace));
            }

            if (string.IsNullOrEmpty(ec.MappingName) == false | string.IsNullOrEmpty(ec.ViewName) == false)
            {
                et.Attributes.Add(new MappingNameDynAttribute(ec.MappingName));
            }

            if (string.IsNullOrEmpty(ec.Comment) == false)
            {
                et.Attributes.Add(new CommentDynAttribute(ec.Comment));
            }

            if (string.IsNullOrEmpty(ec.CustomData) == false)
            {
                et.Attributes.Add(new CustomDataDynAttribute(ec.CustomData));
            }

            if (string.IsNullOrEmpty(ec.AdditionalSqlScript) == false)
            {
                et.Attributes.Add(new AdditionalSqlScriptDynAttribute(ec.AdditionalSqlScript));
            }

            if (ec.IsReadOnly)
            {
                et.Attributes.Add(new ReadOnlyDynAttribute());
            }

            if (ec.IsAutoPreLoad)
            {
                et.Attributes.Add(new AutoPreLoadDynAttribute());
            }

            if (ec.IsBatchUpdate)
            {
                et.Attributes.Add(new BatchUpdateDynAttribute(ec.BatchSize));
            }

            if (ec.IsRelation)
            {
                et.Attributes.Add(new RelationDynAttribute());
            }

            foreach (PropertyConfiguration pc in ec.Properties)
            {
                if (pc.IsInherited)
                {
                    continue;
                }

                DynPropertyConfiguration property = new DynPropertyConfiguration(pc.Name);
                property.PropertyType             = pc.PropertyType;
                property.IsInherited              = pc.IsInherited;
                property.IsQueryProperty          = pc.IsQueryProperty;
                property.IsReadOnly               = pc.IsReadOnly;
                property.InheritEntityMappingName = pc.InheritEntityMappingName;
                //property.IsCompoundUnit = pc.IsCompoundUnit;
                property.Comment               = pc.Comment;
                property.CustomData            = pc.CustomData;
                property.IsContained           = pc.IsContained;
                property.IsFriendKey           = pc.IsFriendKey;
                property.IsIndexProperty       = pc.IsIndexProperty;
                property.IsIndexPropertyDesc   = pc.IsIndexPropertyDesc;
                property.IsInherited           = pc.IsInherited;
                property.IsLazyLoad            = pc.IsLazyLoad;
                property.IsNotNull             = pc.IsNotNull;
                property.IsPrimaryKey          = pc.IsPrimaryKey;
                property.IsQueryProperty       = pc.IsQueryProperty;
                property.IsReadOnly            = pc.IsReadOnly;
                property.IsRelationKey         = pc.IsRelationKey;
                property.IsSerializationIgnore = pc.IsSerializationIgnore;
                property.MappingName           = pc.MappingName;
                property.Name = pc.Name;
                property.PropertyMappingColumnType = pc.PropertyMappingColumnType;
                property.PropertyType      = pc.PropertyType;
                property.QueryOrderBy      = pc.QueryOrderBy;
                property.QueryType         = pc.QueryType;
                property.QueryWhere        = pc.QueryWhere;
                property.RelatedForeignKey = pc.RelatedForeignKey;
                property.RelatedType       = pc.RelatedType;
                property.RelationType      = pc.RelationType;
                property.SqlDefaultValue   = pc.SqlDefaultValue;
                property.SqlType           = pc.SqlType;

                if (pc.IsFriendKey)
                {
                    property.Attributes.Add(new FriendKeyDynAttribute(pc.RelatedType));
                }

                if (string.IsNullOrEmpty(pc.SqlType) == false)
                {
                    property.Attributes.Add(new SqlTypeDynAttribute(pc.SqlType));
                }

                if (pc.IsReadOnly)
                {
                    property.Attributes.Add(new ReadOnlyDynAttribute());
                }

                //if (pc.IsCompoundUnit)
                //    property.Attributes.Add(new CompoundUnitDynAttribute());

                if (pc.IsPrimaryKey)
                {
                    property.Attributes.Add(new PrimaryKeyDynAttribute());
                }

                if (pc.IsRelationKey)
                {
                    property.Attributes.Add(new RelationKeyDynAttribute(pc.RelatedForeignKey));
                }

                if (pc.IsIndexPropertyDesc)
                {
                    property.Attributes.Add(new PrimaryKeyDynAttribute());
                }

                if (pc.IsNotNull)
                {
                    property.Attributes.Add(new NotNullDynAttribute());
                }

                if (pc.IsSerializationIgnore)
                {
                    property.Attributes.Add(new SerializationIgnoreDynAttribute());
                }

                if (string.IsNullOrEmpty(pc.MappingName) == false)
                {
                    property.Attributes.Add(new MappingNameDynAttribute(pc.MappingName));
                }

                if (string.IsNullOrEmpty(pc.Comment) == false)
                {
                    property.Attributes.Add(new CommentDynAttribute(pc.Comment));
                }

                if (string.IsNullOrEmpty(pc.CustomData) == false)
                {
                    property.Attributes.Add(new CustomDataDynAttribute(pc.CustomData));
                }

                if (pc.IsQueryProperty)
                {
                    QueryType queryType = (QueryType)Enum.Parse(typeof(QueryType), pc.QueryType);

                    switch (queryType)
                    {
                    case QueryType.CustomQuery:
                        CustomQueryDynAttribute customQueryDynAttribute = new CustomQueryDynAttribute(pc.QueryWhere);
                        customQueryDynAttribute.OrderBy      = pc.QueryOrderBy;
                        customQueryDynAttribute.RelationType = pc.RelationType;
                        customQueryDynAttribute.LazyLoad     = pc.IsLazyLoad;
                        property.Attributes.Add(customQueryDynAttribute);
                        break;

                    case QueryType.FkQuery:
                        FkQueryDynAttribute fkQueryDynAttribute = new FkQueryDynAttribute(pc.RelatedForeignKey);     //zml ???
                        fkQueryDynAttribute.AdditionalWhere = pc.QueryWhere;
                        fkQueryDynAttribute.LazyLoad        = pc.IsLazyLoad;
                        fkQueryDynAttribute.OrderBy         = pc.QueryOrderBy;
                        property.Attributes.Add(fkQueryDynAttribute);

                        property.IsArray = true;
                        break;

                    case QueryType.FkReverseQuery:
                        FkReverseQueryDynAttribute fkReverseQueryDynAttribute = new FkReverseQueryDynAttribute(true);
                        fkReverseQueryDynAttribute.LazyLoad = pc.IsLazyLoad;
                        property.Attributes.Add(fkReverseQueryDynAttribute);
                        break;

                    case QueryType.ManyToManyQuery:
                        ManyToManyQueryDynAttribute manyToManyQueryDynAttribute = new ManyToManyQueryDynAttribute(pc.RelationType);
                        manyToManyQueryDynAttribute.AdditionalWhere = pc.QueryWhere;
                        manyToManyQueryDynAttribute.LazyLoad        = pc.IsLazyLoad;
                        manyToManyQueryDynAttribute.OrderBy         = pc.QueryOrderBy;
                        property.Attributes.Add(manyToManyQueryDynAttribute);

                        property.IsArray = true;
                        break;

                    case QueryType.PkQuery:
                        PkQueryDynAttribute pkQueryDynAttribute = new PkQueryDynAttribute();
                        pkQueryDynAttribute.LazyLoad = pc.IsLazyLoad;
                        property.Attributes.Add(pkQueryDynAttribute);
                        break;

                    case QueryType.PkReverseQuery:
                        PkReverseQueryDynAttribute pkReverseQueryDynAttribute = new PkReverseQueryDynAttribute(true);
                        pkReverseQueryDynAttribute.LazyLoad = pc.IsLazyLoad;
                        property.Attributes.Add(pkReverseQueryDynAttribute);
                        break;
                    }
                }

                if (pc.IsIndexProperty)
                {
                    IndexPropertyDynAttribute indexPropertyDynAttribute = new IndexPropertyDynAttribute(pc.IsIndexPropertyDesc);
                    property.Attributes.Add(indexPropertyDynAttribute);
                }

                if (property.IsQueryProperty)
                {
                    if (property.IsArray)
                    {
                        property.PropertyOriginalEntityType = property.PropertyType.Replace(nameSpace + ".", "").Replace("ArrayList", "");
                    }
                    else
                    {
                        property.PropertyOriginalEntityType = property.PropertyType.Replace(nameSpace + ".", "");
                    }
                }
                else
                {
                    property.PropertyOriginalEntityType = property.PropertyType;
                }


                et.AddProperty(property);
            }
            return(et);
        }
 public DynPropertyConfigurationCollection(DynEntityType dynEntityType)
 {
     this._dynEntityType = dynEntityType;
 }
Пример #15
0
 public static DbType[] GetCreatePropertyMappingColumnTypes(DynEntityType entityType)
 {
     return(GetCreatePropertyMappingColumnTypes(MetaDataManager.GetEntityConfiguration(entityType.FullName)));
 }
Пример #16
0
        /// <summary>
        /// Gets the create property values.
        /// </summary>
        /// <param name="entityType">The type.</param>
        /// <param name="obj">The obj.</param>
        /// <returns>The values.</returns>
        public static object[] GetCreatePropertyValues(DynEntityType entityType, DynEntity obj)
        {
            Check.Require(obj != null, "obj could not be null.");

            return(GetPropertyValues(obj, GetCreatePropertyMappingColumnNames(entityType)));
        }
Пример #17
0
        /// <summary>
        /// new an EntityConfiguration from an EntityType
        /// </summary>
        /// <param name="entityType"></param>
        /// <returns></returns>
        public static EntityConfiguration EntityType2EntityConfiguration(DynEntityType entityType)
        {
            EntityConfiguration ec = new EntityConfiguration();

            ec.Name = entityType.FullName;

            EntityDynAttribute attr = entityType.GetCustomAttribute(typeof(MappingNameDynAttribute));

            if (attr != null)
            {
                ec.MappingName = (attr as MappingNameDynAttribute).Name;
            }
            else
            {
                ec.MappingName = entityType.Name;
            }

            entityType.MappingName = ec.MappingName;


            attr = entityType.GetCustomAttribute(typeof(CommentDynAttribute));
            if (attr != null)
            {
                ec.Comment = (attr as CommentDynAttribute).Content;
            }
            else
            {
                ec.Comment = "";
            }

            entityType.Comment = ec.Comment;

            attr = entityType.GetCustomAttribute(typeof(BatchUpdateDynAttribute));
            if (attr != null)
            {
                ec.BatchSize = (attr as BatchUpdateDynAttribute).BatchSize;
            }
            else
            {
                ec.BatchSize = 0;
            }

            entityType.BatchSize = ec.BatchSize;

            if (string.IsNullOrEmpty(entityType.BaseEntityName))
            {
                ec.BaseEntity = null;
            }

            else
            {
                ec.BaseEntity = entityType.Namespace + "." + entityType.BaseEntityName;
            }

            attr = entityType.GetCustomAttribute(typeof(CustomDataDynAttribute));
            if (attr != null)
            {
                ec.CustomData = (attr as CustomDataDynAttribute).Data;
            }
            else
            {
                ec.CustomData = "";
            }

            entityType.CustomData = ec.CustomData;

            attr = entityType.GetCustomAttribute(typeof(AdditionalSqlScriptDynAttribute));
            if (attr != null)
            {
                ec.AdditionalSqlScript = (attr as AdditionalSqlScriptDynAttribute).Sql;
            }
            else
            {
                ec.AdditionalSqlScript = "";
            }

            entityType.AdditionalSqlScript = ec.AdditionalSqlScript;

            attr = entityType.GetCustomAttribute(typeof(ReadOnlyDynAttribute));
            if (attr != null)
            {
                ec.IsReadOnly = true;
            }
            else
            {
                ec.IsReadOnly = false;
            }
            entityType.IsReadOnly = ec.IsReadOnly;

            attr = entityType.GetCustomAttribute(typeof(AutoPreLoadDynAttribute));
            if (attr != null)
            {
                ec.IsAutoPreLoad = true;
            }
            else
            {
                ec.IsAutoPreLoad = false;
            }
            entityType.IsAutoPreLoad = ec.IsAutoPreLoad;

            attr = entityType.GetCustomAttribute(typeof(RelationDynAttribute));
            if (attr != null)
            {
                ec.IsRelation = true;
            }
            else
            {
                ec.IsRelation = false;
            }
            entityType.IsRelation = ec.IsRelation;

            //根据DynPropertyConfigurationCollection构造PropertyConfiguration
            List <PropertyConfiguration> pcList = new List <PropertyConfiguration>();
            //TODO:此处如果支持继承关系需要调整
            DynPropertyConfigurationCollection allProperties = entityType.GetProperties();

            foreach (DynPropertyConfiguration property in allProperties)
            {
                PropertyConfiguration pc = new PropertyConfiguration();

                pc.IsInherited = property.IsInherited;
                pc.InheritEntityMappingName = property.InheritEntityMappingName;

                attr            = property.GetPropertyAttribute(typeof(PrimaryKeyDynAttribute));
                pc.IsPrimaryKey = (attr != null);

                IndexPropertyDynAttribute ipa = property.GetPropertyAttribute(typeof(IndexPropertyDynAttribute)) as IndexPropertyDynAttribute;
                if (ipa != null)
                {
                    pc.IsIndexProperty           = true;
                    pc.IsIndexPropertyDesc       = ipa.IsDesc;
                    property.IsIndexProperty     = true;
                    property.IsIndexPropertyDesc = ipa.IsDesc;
                }

                attr         = property.GetPropertyAttribute(typeof(NotNullDynAttribute));
                pc.IsNotNull = (attr != null);

                attr = property.GetPropertyAttribute(typeof(SerializationIgnoreDynAttribute));
                pc.IsSerializationIgnore = (attr != null);

                RelationKeyDynAttribute rka = property.GetPropertyAttribute(typeof(RelationKeyDynAttribute)) as RelationKeyDynAttribute;
                if (rka != null)
                {
                    pc.IsRelationKey           = true;
                    pc.RelatedType             = GetOutputNamespace(rka.RelatedType) + "." + rka.RelatedType;
                    pc.RelatedForeignKey       = rka.RelatedPk;
                    property.IsRelationKey     = true;
                    property.RelatedType       = pc.RelatedType;
                    property.RelatedForeignKey = rka.RelatedPk;
                }

                FriendKeyDynAttribute fka = property.GetPropertyAttribute(typeof(FriendKeyDynAttribute)) as FriendKeyDynAttribute;
                if (fka != null)
                {
                    pc.IsFriendKey             = true;
                    pc.RelatedForeignKey       = fka.RelatedEntityPk;
                    pc.RelatedType             = GetOutputNamespace(fka.RelatedEntityType) + "." + fka.RelatedEntityType;
                    property.IsFriendKey       = true;
                    property.RelatedForeignKey = fka.RelatedEntityPk;
                    property.RelatedType       = pc.RelatedType;
                }

                MappingNameDynAttribute mna = property.GetPropertyAttribute(typeof(MappingNameDynAttribute)) as MappingNameDynAttribute;
                if (mna != null)
                {
                    pc.MappingName       = mna.Name;
                    property.MappingName = mna.Name;
                }

                CommentDynAttribute ca = property.GetPropertyAttribute(typeof(CommentDynAttribute)) as CommentDynAttribute;
                if (ca != null)
                {
                    pc.Comment       = ca.Content;
                    property.Comment = ca.Content;
                }

                attr = property.GetPropertyAttribute(typeof(CustomDataDynAttribute));
                if (attr != null)
                {
                    pc.CustomData = ((CustomDataDynAttribute)attr).Data;
                }

                pc.IsReadOnly = property.IsReadOnly;
                pc.Name       = property.Name;


                SqlTypeDynAttribute sta = property.GetPropertyAttribute(typeof(SqlTypeDynAttribute)) as SqlTypeDynAttribute;
                if (sta != null && (!string.IsNullOrEmpty(sta.Type)))
                {
                    pc.SqlType               = sta.Type;
                    pc.SqlDefaultValue       = sta.DefaultValue;
                    property.SqlType         = sta.Type;
                    property.SqlDefaultValue = sta.DefaultValue;
                }

                QueryDynAttribute qa = property.GetPropertyQueryAttribute();
                if (qa != null)
                {
                    pc.IsQueryProperty = true;
                    pc.QueryType       = qa.QueryType.ToString();

                    property.PropertyOriginalEntityType = property.PropertyType;
                    property.IsQueryProperty            = true;


                    string propertyEntityType = property.PropertyType;
                    //if (property.IsArray)
                    //{
                    //    propertyEntityType = property.PropertyType;
                    //}
                    DynQueryDescriber describer = new DynQueryDescriber(qa, property, propertyEntityType, entityType.Name);

                    pc.IsLazyLoad         = describer.LazyLoad;
                    pc.QueryOrderBy       = describer.OrderBy;
                    pc.QueryWhere         = describer.Where;
                    property.IsLazyLoad   = describer.LazyLoad;
                    property.QueryOrderBy = describer.OrderBy;
                    property.QueryWhere   = describer.Where;

                    if (describer.RelationType != null)
                    {
                        pc.RelationType = GetOutputNamespace(describer.RelationType) + "." + describer.RelationType;
                    }
                    pc.IsContained             = describer.Contained;
                    pc.RelatedForeignKey       = describer.RelatedForeignKey;
                    property.IsContained       = describer.Contained;
                    property.RelatedForeignKey = describer.RelatedForeignKey;
                    if (describer.RelatedType != null)
                    {
                        pc.RelatedType       = GetOutputNamespace(describer.RelatedType) + "." + describer.RelatedType;
                        property.RelatedType = pc.RelatedType;
                    }

                    if (property.IsArray)
                    {
                        pc.PropertyType = GetOutputNamespace(property.PropertyType) + "." + property.PropertyType + "ArrayList";
                    }
                    else
                    {
                        pc.PropertyType = GetOutputNamespace(property.PropertyType) + "." + property.PropertyType;
                    }
                    property.PropertyType = pc.PropertyType;

                    if (qa.QueryType == QueryType.FkReverseQuery)
                    {
                        if (string.IsNullOrEmpty(describer.RelatedForeignKeyType) != true)
                        {
                            pc.PropertyMappingColumnType = describer.RelatedForeignKeyType ?? typeof(string).ToString();
                        }
                        else
                        {
                            pc.PropertyMappingColumnType = string.IsNullOrEmpty(describer.RelatedForeignKeyType) ? "" : typeof(string).ToString();
                        }
                        property.PropertyMappingColumnType = pc.PropertyMappingColumnType;
                    }

                    if (qa.QueryType == QueryType.FkQuery)
                    {
                        pc.RelatedForeignKey = describer.RelatedForeignKey;
                        pc.RelatedType       = GetOutputNamespace(describer.RelatedType) + "." + describer.RelatedType;

                        property.RelatedForeignKey = describer.RelatedForeignKey;
                        property.RelatedType       = pc.RelatedType;
                    }
                }
                else
                {
                    pc.PropertyType = property.PropertyType;
                }

                pcList.Add(pc);
            }
            ec.Properties = pcList.ToArray();

            return(ec);
        }