web api如何忽略ODataQueryOptions

时间:2016-02-11 11:47:48

标签: asp.net-web-api odata

我有一个没有实体框架的odata控制器

[EnableQuery]
public HttpResponseMessage Get(ODataQueryOptions<TicketApp> queryOptions)
{
    List<TicketApp> tList = new List<TicketApp>();
    tList = BL.GetTickets(queryOptions);
    return Request.CreateResponse(HttpStatusCode.OK, new PageResult<TicketApp>(tList, Request.ODataProperties().NextLink, tList.Count()));
}

在我的BL.GetTickets中,我获得了查询我的数据库的所有过滤器(没有实体) 所有工作,但当我的tList返回odata应用查询,结果为空

如何在不应用odata查询的情况下返回完整列表? 感谢

例如,如果我这样做

api/app/ticket?$top=10&$skip=20

BL.GetTickets gets 10 tikets skipping 20, the tList has 10 items

odata skip 20 and get 10 from tList

更新1

如果客户端需要扩展项目,我需要进行intercepet,如果我删除了EnableQuery,则无法扩展复杂属性。

2 个答案:

答案 0 :(得分:0)

Remove the setup= attribute from your method.

答案 1 :(得分:0)

解决方案是:

使用[AutoExpand]

删除带有数据注释的每个复杂属性的[EnableQuery]广告标记
相关问题