Is there a way to skip pagination on nested collection
@Sreejithpin is already working on this.
Since Mar 30, 2021.
- Dominant language
- C#
- Stars
- 864
- Forks
- 467
- PR merge metrics
- No merged PRs in 30d
Description
I have an API built using .netcore3.1 and OData which returns a collection of list and each item in the list has another collection property.
when i apply [EnableQuery(PageSize =10)] attribute on the controller method, i get odata response with 10 items. when i expand the collection property, if it has more than 10 records, it gets paginated as well.
I'm looking for a way to apply the pagination only for the main collection not the nested collection.
Assemblies affected
Microsoft.AspNetCore.OData 7.5.6
Expected result
Full set of nested collection property without nextLink ( please see the below actual result, i'm looking to have the all the books included in the respon)
Actual result
{
"@odata.context": "https://localhost:5001/odata/$metadata#Author(Books())",
"value": [
{
"EntityId": "1",
"Name": "John"
"Books": [
{
"Name": "Test"
}
]
},
{
// omitted for brevity
},
{
"EntityId": "10",
"Name": "Tony"
"Books": [
{
"Name": "Test"
},
{
// omitted for brevity
}
],
"Books@odata.nextLink": "http://localhost:5000/odata/Author('10')/Books?$skiptoken=BookId-%2710%27"
}
],
"odata.nextLink": "http://localhost:5000/odata/Author?expand=Books&$skiptoken=EntityId-%2710%27"
}
Additional detail
app.UseEndpoints(endpoints => {
endpoints.MapControllers();
endpoints.EnableDependencyInjection();
endpoints.Select().Filter().OrderBy().Count().Expand().MaxTop(100).SkipToken();
endpoints.MapODataRoute("odata", "odata", GetEdmModel(app.ApplicationServices));
});
//
private IEdmModel GetEdmModel(IServiceProvider serviceProvider)
{
var odataBuilder = new ODataConventionModelBuilder(serviceProvider);
odataBuilder.EntitySet<Author>("Author").EntityType.HasKey(x = x.EntityId);
odataBuilder.EntitySet<Book>("Book");
return odataBuilder.GetEdmModel();
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.