Exemplo n.º 1
0
        public OrmLitePageResult <Article> SelectList(string title, int?typeId,
                                                      int pageIndex, int pageSize)
        {
            StringBuilder sb = new StringBuilder();
            var           ps = DictBuilder.New();

            sb.Append("1=1");
            var orderBy = "id desc";

            title = SqlInjection.Filter(title);
            if (!string.IsNullOrEmpty(title))
            {
                sb.AppendFormat(" and Title like '%{0}%'", title);
            }

            if (typeId > 0)
            {
                orderBy = "OrderNum";
                sb.AppendFormat(" and TypeId={0}", typeId);
            }


            var factor = new OrmLitePageFactor
            {
                Conditions = sb.ToString(),
                PageIndex  = pageIndex,
                PageSize   = pageSize,
                OrderBy    = orderBy,
                Params     = ps
            };

            return(_articleDao.SelectPage(factor));
        }