Example #1
0
        public static FilterDefinition <MongoContentEntity> Build(ODataUriParser query, Schema schema)
        {
            var search = query.ParseSearch();

            if (search != null)
            {
                return(Filter.Text(SearchTermVisitor.Visit(search.Expression).ToString()));
            }

            var filter = query.ParseFilter();

            if (filter != null)
            {
                return(FilterVisitor.Visit(filter.Expression, schema));
            }

            return(null);
        }
Example #2
0
        public static FilterDefinition <MongoContentEntity> Build(ODataUriParser query, Schema schema)
        {
            SearchClause search;

            try
            {
                search = query.ParseSearch();
            }
            catch (ODataException ex)
            {
                throw new ValidationException("Query $search clause not valid", new ValidationError(ex.Message));
            }

            if (search != null)
            {
                return(Filter.Text(SearchTermVisitor.Visit(search.Expression).ToString()));
            }

            FilterClause filter;

            try
            {
                filter = query.ParseFilter();
            }
            catch (ODataException ex)
            {
                throw new ValidationException("Query $filter clause not valid", new ValidationError(ex.Message));
            }

            if (filter != null)
            {
                return(FilterVisitor.Visit(filter.Expression, schema));
            }

            return(null);
        }