コード例 #1
0
        public static IDictionary <long, BaseTable> listBaseTableQueryMap(UIProgress prgDialog, Session session, string qs, IList <long> ids, bool cloneResult)
        {
            IDictionary <long, BaseTable>     resMap = new Dictionary <long, BaseTable>(ids.Count);
            ICollection <ICollection <long> > chunks = splitIntoChunks(ids, 1900);

            if (prgDialog != null)
            {
                prgDialog.Indeterminate = false;
                prgDialog.TotalTimes    = chunks.Count;
            }
            foreach (ICollection <long> chunk in chunks)
            {
                IList <BaseTable> objs = session.createQuery(qs).setCacheable(false).setParameterList("ids", chunk).list();

                foreach (BaseTable obj in objs)
                {
                    if (cloneResult)
                    {
                        obj = (BaseTable)obj.clone();
                    }
                    resMap[obj.Id] = obj;
                }
                if (prgDialog != null)
                {
                    prgDialog.incrementProgress(1);
                }
            }

            return(resMap);
        }
コード例 #2
0
        private static ICollection <BaseTable> listBaseTableQuery(UIProgress prgDialog, Session session, long?projectId, string qs, Type bindClass, ICollection <long> ids, bool cloneResult)
        {
            IList <BaseTable> resList = new List <BaseTable>(ids.Count);
            ICollection <ICollection <long> > chunks = splitIntoChunks(ids, 1900);

            if (prgDialog != null)
            {
                prgDialog.Indeterminate = false;
                prgDialog.TotalTimes    = chunks.Count;
                prgDialog.setProgress("Loading items...", 0);
            }

            ResultTransformer rt = null;

            if (bindClass != null)
            {
                rt = Transformers.aliasToBean(bindClass);
            }
            foreach (ICollection <long> chunk in chunks)
            {
                Query q = session.createQuery(qs).setCacheable(false).setParameterList("ids", chunk);
                if (projectId != null)
                {
                    q.setLong("prjId", projectId);
                }
                if (rt != null)
                {
                    q = q.setResultTransformer(rt);
                }
                IList <BaseTable> objs = q.list();

                foreach (BaseTable obj in objs)
                {
                    if (cloneResult)
                    {
                        obj = (BaseTable)obj.clone();
                    }
                    resList.Add(obj);
                }

                if (prgDialog != null)
                {
                    prgDialog.incrementProgress(1);
                }
            }

            return(resList);
        }