Exemple #1
0
        public void Parse(string queryString)
        {
            if (!string.IsNullOrEmpty(queryString))
            {
                var queryStrings = HttpUtility.ParseQueryString(queryString);
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$filter"))
                {
                    string filter   = queryStrings["$filter"];
                    var    language = new ODataFilterLanguage();
                    Expression <Func <T, bool> > predicateExpression = language.Parse <T>(filter);
                    Filter = predicateExpression.Compile();
                }
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$top"))
                {
                    string top = queryStrings["$top"];
                    ParseTop(top);
                }
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$skip"))
                {
                    string skip = queryStrings["$skip"];
                    ParseSkip(skip);
                }

                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$orderby"))
                {
                    string            orderby       = queryStrings["$orderby"];
                    OrderByClause <T> orderbyClause = new OrderByClause <T>();
                    orderbyClause.Parse(orderby);
                    Sort          = orderbyClause.RootExpression;
                    SortDirection = orderbyClause.Direction;
                }
            }
        }