Ejemplo n.º 1
0
        protected IQueryable <T> ApplyBrowse <T>(IQueryable <T> q, string sortCol, IEnumerable <string> orderedValues, string sortDir, int?page, int?pageSize, IDictionary <string, string> colMapper = null)
        {
            ViewBag.TotalItemCount = q.Count();
            bool isAscending = AspHelpers.IsSortDirAscending(sortDir);

            ViewBag.SortCol = sortCol;
            ViewBag.SortDir = sortDir;
            q = q.OrderByField(sortCol, orderedValues, isAscending);
            q = ApplyPagination(q, page, pageSize);
            return(q);
        }
Ejemplo n.º 2
0
        protected IQueryable <T> ApplySort <T>(IQueryable <T> q, string sortCol, string sortDir, IDictionary <string, string> colMapper = null)
        {
            var m = new Dictionary <string, string>(colMapper ?? NoMappings);

            if (!m.ContainsKey("CreatedAt"))
            {
                m["CreatedAt"] = "CreatedAtUtc";
            }
            sortCol = StringHelpers.TrimOrNull(sortCol);
            bool isAscending = AspHelpers.IsSortDirAscending(sortDir);

            ViewBag.SortCol = sortCol;
            ViewBag.SortDir = sortDir;
            if (sortCol != null)
            {
                sortCol = m.FindOrMissing(sortCol, sortCol);
                q       = q.OrderByField(sortCol, isAscending);
            }
            return(q);
        }