Forked from ODataTeam/ODataQueryOptionParserParsingQueryOptions.cs
Created
March 3, 2018 11:57
-
-
Save vmandic/9d74d30892cd2cb005f0baebfe4bf428 to your computer and use it in GitHub Desktop.
Parsing query options using query option parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dictionary<string, string> options = new Dictionary<string, string>() | |
{ | |
{"$select" , "ID" }, | |
{"$expand" , "ProductDetail" }, | |
{"$filter" , "Categories/any(d:d/ID gt 1)" }, | |
{"$orderby" , "ID desc" }, | |
{"$top" , "1" }, | |
{"$count" , "true" }, | |
{"$search" , "tom" }, | |
}; | |
IEdmType type = model.FindDeclaredType("ODataDemo.Product"); | |
IEdmNavigationSource source = model.FindDeclaredEntitySet("Products"); | |
ODataQueryOptionParser parser | |
= new ODataQueryOptionParser(model, type, source, options); | |
SelectExpandClause selectExpand = | |
parser.ParseSelectAndExpand(); //parse $select, $expand | |
FilterClause filter = parser.ParseFilter(); // parse $filter | |
OrderByClause orderby = parser.ParseOrderBy(); // parse $orderby | |
SearchClause search = parser.ParseSearch(); // parse $search | |
long? top = parser.ParseTop(); // parse $top | |
long? skip = parser.ParseSkip(); // parse $skip (null) | |
bool? count = parser.ParseCount(); // parse $count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment