星空网 > 软件开发 > ASP.net

OData V4 系列 Action 与 Function

       OData 学习目录

       了解过WebApi的都知道,WebApi默认方法 Get、Post、Put,如果增加其它过多Post方法即不能识别,还需增加其它配制,请求的Url还需加上Controller及Action,与Restful设计不一致,Odata可以解决这样的问题。

    配制路由服务       

      builder.Namespace = "ProductService";      builder.EntityType<Product>().Collection        .Function("MostExpensive") //函数路由        .Returns<double>();      builder.Namespace = "ProductService";      builder.EntityType<Product>()        .Action("Rate") //Action路由        .Parameter<int>("Rating");

         通过Get请求 MostExpensive 会出现如下错误
         OData V4 系列  Action 与 Function

              修改Web.config   <modules runAllManagedModulesForAllRequests="true"></modules>

              OData V4 系列  Action 与 Function

              OData V4 系列  Action 与 Function

               Action 请求              

       $.ajax({        url: "/Odata/Products(" + id + ")/ProductService.Rate",        type: "POST",        contentType: "application/json; charset=utf-8",        dataType: "JSON",        data: JSON.stringify({ Rating: 5 }),        success: function (r) {          debugger;        },        error: function (e) {          debugger;        }      });

 

             

 




原标题:OData V4 系列 Action 与 Function

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

餐饮进入“平价时代” 这支地方队开始崛起 :https://www.xlkjsw.com/news/72960.html
“二厂汽水”之争 没有李逵也没有李鬼 :https://www.kjdsnews.com/a/1837894.html
“二厂汽水”之争 没有李逵也没有李鬼 :https://www.xlkjsw.com/news/72961.html
在北美市场卖路亚渔具 这公司攻破技术难关后年销售额破5亿 :https://www.kjdsnews.com/a/1837895.html
在北美市场卖路亚渔具 这公司攻破技术难关后年销售额破5亿 :https://www.xlkjsw.com/news/72962.html
2024清远黄腾峡漂流开放时间:https://www.vstour.cn/a/388209.html
去日本入住酒店,东西随意用却有一个特殊“要:https://www.vstour.cn/a/411241.html
中国有哪些著名的酒店品牌。:https://www.vstour.cn/a/411242.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流