web api 如何忽略 ODataQueryOptions

web api how to ignore ODataQueryOptions

我有一个没有 entity framework

的 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 returns odata 对其应用查询并且结果为空时

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

例如,如果我这样做

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

如果客户端需要展开项,我需要拦截,如果我去掉EnableQuery复杂属性就无法展开。

从您的方法中删除 EnableQuery 属性。

解决方法是这样的:

使用 [AutoExpand]

删除每个复合体 属性 中带有数据注释的 [EnableQuery] 广告标记