コード例 #1
0
        public IList <T> HighSelect <T>(IList <PropertPo> pos)
        {
            Conjunction andCon   = Restrictions.Conjunction();
            Disjunction orCon    = Restrictions.Disjunction();
            ICriteria   criteria = Session.CreateCriteria(typeof(T));

            foreach (PropertPo po in pos)
            {
                AbstractCriterion criterion = PropertUtils.ReflectGetValue(po.methodName, po.Forname, po.Values.ToArray <string>());

                if (po.LogicalMethod.Equals("And"))
                {
                    andCon.Add(criterion);
                }
                else
                {
                    orCon.Add(criterion);
                }
            }

            if (andCon.ToString().Length > 2 && orCon.ToString().Length > 2)
            {
                criteria.Add(Restrictions.And(andCon, orCon));
            }
            else
            if (andCon.ToString().Length > 2)
            {
                criteria.Add(andCon);
            }
            else if (orCon.ToString().Length > 2)
            {
                criteria.Add(orCon);
            }


            IList <T> list = criteria.List <T>();

            return(list);
        }