If $top is not defined in query, return all rows #2308
Closed
Description
I use asp.net core 3.1
and Microsoft.AspNetCore.OData 7.5.0
with NHibernate and FluentNHibernate
.
I config OData in Startup.cs like this:
endpoint.MapControllers();
endpoint.EnableDependencyInjection();
endpoint
.Select()
.Expand(QueryOptionSetting.Disabled)
.Filter()
.OrderBy()
.Count()
.MaxTop(100)
;
and use in controller like:
[HttpGet("/records"), EnableQuery, Authorize()]
public IQueryable<Record> GetRecords()
{
return _deviceData.GetRecords();
}
and sevice like:
public interface IDeviceData
{
...
IQueryable<Record> GetRecords();
...
}
Every thing is fine But I have one problem.
When user not define $top
in query, return all rows and MaxTop
not effect (!!!), but user define $top
every thing OK (expected result).
Assemblies affected
I Use only Microsoft.AspNetCore.OData 7.X
Expected result
When user not define $top
in query, $top
set to equal MaxTop
(In my sample, return 100 rows).