示例#1
0
        public OrmLitePageResult <Announcement> SelectList(string title, 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);
            }

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

            return(announcementDao.SelectPage(factor));
        }
示例#2
0
        public OrmLitePageResult <Ad> SelectList(string title, int?adTypeId, DateTime?start, DateTime?end,
                                                 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 (adTypeId > 0)
            {
                orderBy = "OrderNum";
                sb.AppendFormat(" and TypeId={0}", adTypeId);
            }

            if (start.HasValue)
            {
                sb.AppendFormat(" and EndTime>@start");
                ps.EQ("start", start.Value);
            }

            if (end.HasValue)
            {
                sb.Append(" and EndTime<@end");
                ps.EQ("end", end.Value.AddDays(1));
            }


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

            return(_adDao.SelectPage(factor));
        }