简体   繁体   中英

ASP.net MVC oData route with parameters

Is it possible to use addresses like that :

http://community.innovacall.local/odata/contactcompetencies(id=GetById/4a50412c-4e36-468a-b7d1-a36a78f02b02)?%24inlinecount=allpages&%24top=10

I handmade a workaround for the second one but I'm sure there is a out of the box solution.

Guid userId = Guid.Parse(Request.Properties["MS_ODataPath"].ToString().Split('(')[1].Split(')')[0].Split('=')[1]);

Could you help me to find it ?

Use & to separate query string options

Use $filter to filter the data (see here ):

community.innovacall.local/odata/contactcompetencies?$filter=id eq 1

Use guid'<value>' for guids (see here )

community.innovacall.local/odata/contactcompetencies?$filter=id eq guid'4a50412c-4e36-468a-b7d1-a36a78f02b02'

Use $inlinecount=allpages to get a count of records (see here )

community.innovacall.local/odata/contactcompetencies?$filter=id eq guid'4a50412c-4e36-468a-b7d1-a36a78f02b02'&$inlinecount=allpages

Use $top and $skip to page through the results (see here and here )

community.innovacall.local/odata/contactcompetencies?$filter=id eq guid'4a50412c-4e36-468a-b7d1-a36a78f02b02'&$inlinecount=allpages&$top=10&$skip=10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM