简体   繁体   English

带参数的ASP.net MVC o数据路由

[英]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 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 ): 使用$filter过滤数据(请参阅此处 ):

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

Use guid'<value>' for guids (see here ) guid'<value>'用于guid(请参见此处

community.innovacall.local/odata/contactcompetencies?$filter=id eq guid'4a50412c-4e36-468a-b7d1-a36a78f02b02' 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 ) 使用$inlinecount=allpages获取记录数(请参阅此处

community.innovacall.local/odata/contactcompetencies?$filter=id eq guid'4a50412c-4e36-468a-b7d1-a36a78f02b02'&$inlinecount=allpages 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 ) 使用$top$skip翻页结果(请参见此处此处

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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