public static IList<OrderByNode> ParseOrderBy(string orderBy)
 {
     var parser = new ODataExpressionParser(orderBy);
     return parser.ParseOrderBy();
 }
 public static QueryNode ParseFilter(string filter)
 {
     var parser = new ODataExpressionParser(filter);
     return parser.ParseFilter();
 }
Esempio n. 3
0
        public static IList <OrderByNode> ParseOrderBy(string orderBy)
        {
            var parser = new ODataExpressionParser(orderBy);

            return(parser.ParseOrderBy());
        }
Esempio n. 4
0
        private static MobileServiceTableQueryDescription Parse(string tableName, string query, string uriPath)
        {
            bool includeTotalCount = false;
            int? top  = null;
            int? skip = null;

            string[]            selection = null;
            QueryNode           filter    = null;
            IList <OrderByNode> orderings = null;

            IDictionary <string, string> parameters = HttpUtility.ParseQueryString(query);

            foreach (KeyValuePair <string, string> parameter in parameters)
            {
                string key   = parameter.Key;
                string value = parameter.Value;
                if (String.IsNullOrEmpty(key))
                {
                    continue;
                }

                switch (key)
                {
                case ODataOptions.Filter:
                    filter = ODataExpressionParser.ParseFilter(value);
                    break;

                case ODataOptions.OrderBy:
                    orderings = ODataExpressionParser.ParseOrderBy(value);
                    break;

                case ODataOptions.Skip:
                    skip = Int32.Parse(value);
                    break;

                case ODataOptions.Top:
                    top = Int32.Parse(value);
                    break;

                case ODataOptions.Select:
                    selection = value.Split(',');
                    break;

                case ODataOptions.InlineCount:
                    includeTotalCount = "allpages".Equals(value);
                    break;

                default:
                    throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unrecognized query parameter '{0}'.", key), "query");
                }
            }

            var description = new MobileServiceTableQueryDescription(tableName)
            {
                IncludeTotalCount = includeTotalCount,
                Skip = skip,
                Top  = top
            };

            description.UriPath = uriPath;
            if (selection != null)
            {
                ((List <string>)description.Selection).AddRange(selection);
            }
            if (orderings != null)
            {
                ((List <OrderByNode>)description.Ordering).AddRange(orderings);
            }
            description.Filter = filter;

            return(description);
        }
Esempio n. 5
0
        public static QueryNode ParseFilter(string filter)
        {
            var parser = new ODataExpressionParser(filter);

            return(parser.ParseFilter());
        }