public IQueryable <Object> GetModels([FromUri] PageParameterModel page) { int skip = 0; string strSorting = PageParameterModel.GetSortingString(page, "Name", out skip); var models = (from m in db.Models orderby(strSorting) select new { m.Id, m.Name } ).Skip(skip).Take(page.pageSize); return(models); }
// GET: api/Channels/Model public IQueryable <Object> GetChannels([FromUri] PageParameterModel page) { //int skip = (page.pageNumber - 1) * page.pageSize; //string[] sorting = page.sorting.Split(new char[] { ' ' }); //string sortColumn, sortOrder, strSorting; //sortColumn = sortOrder = strSorting = string.Empty; //if (sorting.Length == 2) { // sortColumn = sorting[0]; // sortOrder = sorting[1].ToLower(); //} //if (new Channel().GetType().GetProperty(sortColumn) == null) sortColumn = "ChannelNo"; //if (sortOrder != "asc" && sortOrder != "desc") sortOrder = "asc"; //strSorting = string.Format("{0} {1}", sortColumn, sortOrder); int skip = 0; string strSorting = PageParameterModel.GetSortingString(page, "ChannelNo", out skip); var channels = (from c in db.Channels orderby(strSorting) select new { c.Id, c.ChannelNo, c.MinRange, c.MaxRange, c.Scale, c.DisplayUnit, c.LowerLimit, c.UpperLimit, c.MonitoringTimer } ).Skip(skip).Take(page.pageSize); return(channels); }