Skip to content

If $top is not defined in query, return all rows #2308

Closed
@SMAH1

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).

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions