Ejemplo n.º 1
0
        //创建类型的快速访问。
        private static void iniTypeDynamicAccess(Type parentType, Type childType, EntityRelationMapInfo relation)
        {
            iniDataTypeProAccess(parentType, DEFAULT_KEY_NAME);
            iniDataTypeProAccess(childType, DEFAULT_KEY_NAME);

            if (relation != null)
            {
                iniDataTypeProAccess(parentType, relation.KeyName);
                iniDataTypeProAccess(childType, relation.ForeingKeyName);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 登记对象之间的关系。
        /// </summary>
        /// <typeparam name="T">父对象</typeparam>
        /// <typeparam name="TDetail">子对象</typeparam>
        private static void RegisterRelation <T, TDetail>(EntityRelationMapInfo relation)
            where T : TBaseModel
            where TDetail : TBaseModel
        {
            Type parentType = typeof(T);
            Type childType  = typeof(TDetail);

            if (!RELATION_DATA_TYPE.ContainsKey(parentType))
            {
                RELATION_DATA_TYPE[parentType] = new EntityRelationInfo[] { new EntityRelationInfo(childType, relation) }
            }
            ;
            else
            {
                List <EntityRelationInfo> childsType = new List <EntityRelationInfo>(RELATION_DATA_TYPE[parentType]);
                childsType.Add(new EntityRelationInfo(childType, relation));
                RELATION_DATA_TYPE[parentType] = childsType.ToArray();
            }
            iniTypeDynamicAccess(parentType, childType, relation);
        }
Ejemplo n.º 3
0
 public EntityRelationInfo(Type entity, EntityRelationMapInfo mapInfo)
 {
     EntityType  = entity;
     RelationMap = mapInfo;
 }