简体   繁体   English

odata和webapi一起在同一个控制器中

[英]odata and webapi together in the same controller

I have the ticketController 我有ticketController

public class ticketsController : ODataController
{
}

Is it possible to have this: 是否有可能:

GET     /api/tickets?$skip={record_to_skip}&$top={pageSize}
GET     /api/tickets/{id}
PUT     /api/tickets/{id}
DELETE  /api/request/{id} 

First GET method uses odata routing, the second GET, PUT, and POST uses web api routing 第一个GET方法使用odata路由,第二个GET,PUT和POST使用web api路由

Thanks 谢谢

Yes it is possible but you have to use an OData attribute. 是的,但是您必须使用OData属性。 Your controller should inherit from ApiController not ODataController and on the method/action you want to query paint it with the OData 'Queryable' attribute, check this out for more details: 您的控制器应继承自ApiController而不是ODataController,并且您要查询的方法/操作使用OData'Qeryable'属性绘制它,请查看此内容以获取更多详细信息:

https://ovaismehboob.wordpress.com/2014/01/18/adding-queryable-support-to-asp-net-web-api-controller-action-methods/ https://ovaismehboob.wordpress.com/2014/01/18/adding-queryable-support-to-asp-net-web-api-controller-action-methods/

Also if you search for OData queryable attribute you should get aa load of information back 此外,如果您搜索OData可查询属性,您应该获得一大堆信息

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

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