如何在不改变动作结构的情况下获得OData-WebApi中的结果总数

时间:2015-12-15 09:15:30

标签: c# asp.net-web-api odata

所以,我想为我的webapi项目应用$ inlinecount。 我的api控制器是这样的:

 public class ValuesController : ApiController
     {
         // GET api/values
         [Queryable(PageSize = 1)]
         public IQueryable<string> Get()
         {
             return new string[] { "value1", "value2", "value3", "value4", "value5" }.AsQueryable();
         }
     }

但是,我不想将行动结构改为:

public PageResult<string> Get(ODataQueryOptions<string> queryOptions)
{
    IQueryable results = queryOptions.ApplyTo(values.AsQueryable());
    return new PageResult<string>(results as IEnumerable<string>, Request.GetNextPageLink(), Request.GetInlineCount());
}

为此可以使用QueryableAttribute吗?如果是,怎么样?

0 个答案:

没有答案
相关问题