Exemplo n.º 1
0
        private void queryChildObjects(int parentResultsCount, ArrayList results, IList oldParentsList, String _no_cached_Ids)
        {
            int icount = 0;

            foreach (EntityInfo info in _state.EntityInfo.ChildEntityList)
            {
                if (icount >= parentResultsCount)
                {
                    break;
                }


                ObjectInfo state = new ObjectInfo(info);
                IList      list  = ObjectDB.Find(state, String.Format("Id in ({0})", _no_cached_Ids)).select(_selectItems).list();

                for (int i = 0; i < list.Count; i++)
                {
                    IEntity objc = list[i] as IEntity;
                    // state
                    //objc.state = new ObjectInfo( objc.GetType() ).Copy( _state );
                    results.Add(objc);
                    oldParentsList.RemoveAt(getIndexOfObject(oldParentsList, objc));
                    ObjectPool.Add(objc);
                }

                if (list.Count > 0)
                {
                    icount += list.Count;
                }
            }
        }
Exemplo n.º 2
0
        public static Hashtable getEntityPropertyList(IList _includeEntityPropertyList, Hashtable _ep_ids, Hashtable selectColumn, String order)
        {
            Hashtable hashtable = new Hashtable();

            if (_includeEntityPropertyList == null)
            {
                return(hashtable);
            }

            foreach (EntityPropertyInfo info in _includeEntityPropertyList)
            {
                String   epIds  = "";
                String[] arrIds = new String[] { };
                if (_ep_ids[info.ColumnName] != null)
                {
                    arrIds = _ep_ids[info.ColumnName].ToString().Trim().TrimEnd(',').Split(',');
                }

                foreach (String strId in arrIds)
                {
                    IEntity cacheObj = ObjectPool.FindOne(info.EntityInfo.Type, cvt.ToInt(strId));
                    if (cacheObj != null)
                    {
                        hashtable[getPropertyObjectKey(info.Name, cacheObj.Id)] = cacheObj;
                    }
                    else
                    {
                        epIds = epIds + strId + ",";
                    }
                }
                epIds = epIds.TrimEnd(',');

                if (strUtil.IsNullOrEmpty(epIds))
                {
                    continue;
                }

                String col = selectColumn[info.Name].ToString().Trim().TrimEnd(',');
                if (string.Compare(col, "Id", true) != 0)
                {
                    if (!col.Equals("*") && (("," + col + ",").ToLower().IndexOf(",id,") < 0))
                    {
                        col = "Id," + col;
                    }

                    ObjectInfo cstate = new ObjectInfo(info.EntityInfo);
                    cstate.IsFindChild = true;
                    IList list = ObjectDB.Find(cstate, String.Format("Id in ({0})", epIds)).list();

                    foreach (IEntity objItem in list)
                    {
                        hashtable[getPropertyObjectKey(info.Name, objItem.Id)] = objItem;
                        ObjectPool.Add(objItem);
                    }
                }
            }

            return(hashtable);
        }
Exemplo n.º 3
0
        public static List <T> findAll <T>()
        {
            ObjectInfo state = new ObjectInfo(typeof(T));

            state.includeAll();
            IList list = ObjectDB.FindAll(state);

            return(db.getResults <T>(list));
        }
Exemplo n.º 4
0
        public T findById <T>(int id)
        {
            if (id < 0)
            {
                return(default(T));
            }
            Object obj = ObjectDB.FindById(id, new ObjectInfo(typeof(T)));

            return((T)obj);
        }