OData异常超出了“热门"查询的"0"限制 [英] OData Exception The limit of '0' for Top query has been exceeded
问题描述
我正在使用版本4的OData Web API,当我尝试使用$top
参数查询OData Web Api时,它在出现异常消息后返回我.
URI中指定的查询无效.超出了热门查询"的限制"0".传入请求中的值为"10"
我使用Apache Ignite dotNet LINQ代替实体框架作为数据源,我的OData控制器操作方法如下:
[EnableQuery]
public IQueryable<Productioncurvepnl> GetProductioncurvepnl()
{
Console.WriteLine("Starting query to ignite");
var q = AIgniteClient.IgniteClient.Instance.ProductionCurvePnLCache.AsCacheQueryable().Select(c => c.Value);
return q;
}
自Web API OData V6.0.0
起,您需要启用查询选项才能进行此工作.
可以在WebApiConfig.Register(HttpConfiguration config)
config.Select().Expand().Filter().OrderBy().MaxTop(null).Count();
或直接在您的模型上进行细粒度配置:
[Page(MaxTop = 100)]
public class Products
如果您使用的是模型绑定Fluent API ,并且不能添加属性,则需要附加查询选项.例如.Page(50, 50)
:
builder.EntitySet<AccountRecordDto>("Accounts").EntityType.Expand(1,
"Transactions").Count().Page(50, 50);
更多详细信息可以在文档
I am using OData Web API for Version 4, when I try to query OData web Api using $top
parameter, it return me following exception message.
The query specified in the URI is not valid. The limit of '0' for Top query has been exceeded. The value from the incoming request is '10'
I am using Apache Ignite dotNet LINQ as data source instead of Entity Framework, my OData controller action method is as follows:
[EnableQuery]
public IQueryable<Productioncurvepnl> GetProductioncurvepnl()
{
Console.WriteLine("Starting query to ignite");
var q = AIgniteClient.IgniteClient.Instance.ProductionCurvePnLCache.AsCacheQueryable().Select(c => c.Value);
return q;
}
Since Web API OData V6.0.0
you need to enable query options to have this work.
This can be done globally in the WebApiConfig.Register(HttpConfiguration config)
config.Select().Expand().Filter().OrderBy().MaxTop(null).Count();
or directly on your models, for fine grained configuration:
[Page(MaxTop = 100)]
public class Products
If you're using Model Bound Fluent APIs and cannot add attributes, you'll need to append the query options. For example .Page(50, 50)
:
builder.EntitySet<AccountRecordDto>("Accounts").EntityType.Expand(1,
"Transactions").Count().Page(50, 50);
More details can be found in the documentation
这篇关于OData异常超出了“热门"查询的"0"限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!