예제 #1
0
        /// <summary>
        /// 填充子集合
        /// </summary>
        /// <param name="showTable"></param>
        /// <param name="?"></param>
        public static void FillEntityChidList(IList lst, ShowChildItem showTable)
        {
            Stack <BQLEntityTableHandle> stkTables = new Stack <BQLEntityTableHandle>();
            BQLEntityTableHandle         curTable  = showTable.ChildItem;

            while (true)
            {
                stkTables.Push(curTable);
                curTable = curTable.GetParentTable();
                if (CommonMethods.IsNull(curTable) || string.IsNullOrEmpty(curTable.GetPropertyName()))
                {
                    break;
                }
            }
            IEnumerable    curList     = lst;
            Queue <object> lastObjects = new Queue <object>();
            ScopeList      empty       = new ScopeList();

            while (stkTables.Count > 0)
            {
                BQLEntityTableHandle table    = stkTables.Pop();
                ScopeList            lstScope = null;
                if (stkTables.Count == 0)
                {
                    lstScope = showTable.FilterScope;
                }
                else
                {
                    lstScope = empty;
                }
                FillEntityChidList(curList, table.GetPropertyName(), lastObjects, table.GetParentTable().GetEntityInfo().EntityType, lstScope);
                curList     = lastObjects;
                lastObjects = new Queue <object>();
            }
        }
예제 #2
0
        /// <summary>
        /// 添加子表
        /// </summary>
        /// <param name="table">子表</param>
        public AliasTableMapping AddChildTable(BQLEntityTableHandle table)
        {
            AliasTableMapping            retTable  = null;
            Stack <BQLEntityTableHandle> stkTables = new Stack <BQLEntityTableHandle>();
            BQLEntityTableHandle         curTable  = table;

            do
            {
                stkTables.Push(curTable);
                curTable = curTable.GetParentTable();
            } while (!CommonMethods.IsNull(curTable));

            AliasTableMapping lastTable = null;//上一个表

            while (stkTables.Count > 0)
            {
                BQLEntityTableHandle cTable = stkTables.Pop();

                string pName = cTable.GetPropertyName();
                if (string.IsNullOrEmpty(pName))
                {
                    lastTable = this;
                    retTable  = this;
                }
                else
                {
                    if (!lastTable._dicChildTables.ContainsKey(pName))
                    {
                        EntityInfoHandle  entityInfo = retTable.EntityInfo;
                        EntityMappingInfo mapInfo    = entityInfo.MappingInfo[pName];
                        if (mapInfo != null)
                        {
                            retTable = new AliasTableMapping(cTable, _belongManager, mapInfo);
                            lastTable._dicChildTables[pName] = retTable;
                            lastTable = retTable;
                        }
                        else
                        {
                            throw new MissingMemberException("实体:" + entityInfo.EntityType.FullName + "中找不到属性:" + pName + "");
                        }
                    }
                    else
                    {
                        retTable  = lastTable._dicChildTables[pName];
                        lastTable = retTable;
                    }
                }
            }
            return(retTable);
        }