Exemple #1
0
        public static Project[] GetList(GeneralQuery query = null)
        {
            if (query != null)
            {
                DetachedCriteria exp = DetachedCriteria.For(typeof(Project));
                if (query.date.IsNotEmpty())
                {
                    exp.Add(Restrictions.Ge("StartDate", query.date.ToDateTime()));
                }
                if (query.name.IsNotEmpty())
                {
                    exp.Add(Restrictions.Like("Name", "%" + query.name + "%"));
                }
                switch (query.state)
                {
                case 1:    //全部
                    break;

                case 0:    //初始化
                case 2:    //已启用
                    exp.Add(Restrictions.Eq("IsUse", true));
                    break;

                case 3:    //未启用
                    exp.Add(Restrictions.Eq("IsUse", false));
                    break;
                }
                exp.AddOrder(NHibernate.Criterion.Order.Desc("CrTime"));
                return(FindAll(exp));
            }
            else
            {
                return(FindAll());
            }
        }
Exemple #2
0
        /// <summary>
        /// 通过Request.QuertString构建GeneralQuery
        /// </summary>
        /// <param name="nameValue"></param>
        /// <returns></returns>
        public static GeneralQuery Get(NameValueCollection nameValue)
        {
            var model = new GeneralQuery();

            foreach (var item in typeof(GeneralQuery).GetProperties())
            {
                if (nameValue.AllKeys.Contains(item.Name))
                {
                    if (item.PropertyType == typeof(int))
                    {
                        item.SetValue(model, nameValue[item.Name].ToInt());
                    }
                    else
                    {
                        item.SetValue(model, nameValue[item.Name]);
                    }
                }
            }
            return(model);
        }