Пример #1
0
        public IEnumerable <dynamic> GetDynamicPageList <TResult>(PaginationIn p, string sql, List <Dictionary <string, object> > parameters)
        {
            p.WatchStart();
            int totalCount = 0;
            //sql.QueryPage(p.page, p.rows);

            int pageNumber = p.page;
            int pageSize   = p.rows;

            pageNumber = pageNumber < 1 ? 1 : pageNumber;
            pageSize   = pageSize < 1 ? 10 : pageSize;

            Dictionary <string, object> dic = new Dictionary <string, object>();

            foreach (var item in parameters)
            {
                if (item != null && item.Count > 0)
                {
                    foreach (var q in item)
                    {
                        dic.Add(q.Key, q.Value);
                    }
                }
            }
            var reader = client.GetReader(sql, dic, CommandType.StoredProcedure);
            var list   = reader.Read();

            totalCount = reader.Read <int>().FirstOrDefault();
            p.records  = totalCount;
            p.WatchEnd();
            return(list);
        }
Пример #2
0
        public IEnumerable <dynamic> GetDynamicPageList <TResult>(PaginationIn p, SqlLam <TResult> sql)
        {
            p.WatchStart();
            int totalCount = 0;

            sql.QueryPage(p.page, p.rows);

            var reader = client.GetReader(sql.GetSql(), sql.GetParameters());
            var list   = reader.Read();

            totalCount = reader.Read <int>().FirstOrDefault();
            p.records  = totalCount;
            p.WatchEnd();
            return(list);
        }