问题描述
我对我所启用ODATA查询选项一个asp.net网页API控制器。控制器如下:
[可查询(每页= 10)]
公众的IQueryable< MyDTO>获取(字符串ID)
{
//一些code在这里
}
由于从可查询
属性明显,该控制器始终,如果有时间返回10条记录超过10 MyDTO的
。
我如何能找出10条已全部归还或记录已经被ODATA查询选项过滤掉?
公开的IQueryable< MyDTO>获取(字符串ID,ODataQueryOptions< MyDTO> queryOptions)
{
IQueryable的< MyDTO> allMyDTOs = GetMyDTOs(ID);
ODataQuerySettings设置=新ODataQuerySettings(){每页= 10};
IQueryable的< MyDTO> appliedMyDTOs = queryOptions.ApplyTo(allMyDTOs,设置)为IQueryable的< MyDTO取代;
返回appliedMyDTOs;
}
下面是一些样品。
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options
I have an asp.net web api controller for which I have enabled odata query options. The controller is as follows:
[Queryable(PageSize = 10)]
public IQueryable<MyDTO> Get(string Id)
{
//some code here
}
As obvious from the Queryable
attribute, this controller always returns 10 records at a time if there are more than 10 MyDTO's
.
How can I find out which 10 records have been returned or which records have been filtered out by odata query option?
public IQueryable<MyDTO> Get(string Id, ODataQueryOptions<MyDTO> queryOptions)
{
IQueryable<MyDTO> allMyDTOs = GetMyDTOs(Id);
ODataQuerySettings settings = new ODataQuerySettings() { PageSize = 10 };
IQueryable<MyDTO> appliedMyDTOs = queryOptions.ApplyTo(allMyDTOs, settings) as IQueryable<MyDTO>;
return appliedMyDTOs;
}
Here are some samples.
http://www.asp.net/web-api/overview/odata-support-in-aspnet-web-api/supporting-odata-query-options
这篇关于如何找出哪些记录由Queryable已经被过滤掉的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!