Esempio n. 1
0
        public object GetList(string prefixList, int perPage = 10, int page = 1)
        {
            var param = new Dictionary <string, object>();

            param["PerPage"] = perPage;
            param["Page"]    = page;
            param["Offset"]  = (page - 1) * perPage;

            var ep = Configuration.Endpoints.GetValueOrDefault(prefixList);

            var sqlOrMethod = string.Join("\n", ep.GetList);
            var sqlCount    = string.Join("\n", ep.CountList);

            return(db.Run(conn =>
            {
                var totalRows = 0;
                if (!string.IsNullOrEmpty(sqlCount))
                {
                    totalRows = conn.QueryFirstOrDefault <int>(sqlCount);
                }
                var rows = conn.Query(sqlOrMethod, param).ToList();

                return new { totalRows, perPage, page, rows };
            }));
        }