/// <summary> /// Sets up a PagingSpec from OData query string values in a RouteValueDictionary for a request /// </summary> /// <param name="rvd">RouteValueDictionary for a request</param> /// <returns>the resulting PagingSpec</returns> public static PagingSpec Create(RouteValueDictionary rvd) { var spec = new PagingSpec(); int skip = 0; if (rvd.ContainsKey("$skip")) int.TryParse((string)rvd["$skip"], out skip); int take = int.MaxValue; if (rvd.ContainsKey("$take")) int.TryParse((string)rvd["$take"], out take); else if (rvd.ContainsKey("$top")) int.TryParse((string)rvd["$top"], out take); if (rvd.ContainsKey("$orderby")) spec.Sort = (string)rvd["$orderby"]; if (skip != 0 || take != 0 || spec.Sort != null) { spec.Skip = skip; spec.Take = take; return spec; } else return null; }