AspNetCoreOData icon indicating copy to clipboard operation
AspNetCoreOData copied to clipboard

Ability to override, modify ,or disable Expand -> PageSize?

Open p6345uk opened this issue 2 years ago • 8 comments

I can specify [EnableQuery(PageSize = 1)]

Which returns 1 item

{
    "@odata.context": "",
    "value": [
        {
            "id": "caaac39-b1f4-4fee-d2d2-08d951a5b8b7",
            "name": "Test.txt",
            "description": ""
        }
    ],
    "@odata.nextLink": "...$skip=1"
}

When I add an Expand it returns one item with one item inside also

{
    "@odata.context": "",
    "value": [
        {
            "id": "caaac39-b1f4-4fee-d2d2-08d951a5b8b7",
            "name": "Test.txt",
            "description": "",
            "versions": [
                {
                    "id": "aaaa86ac-4c33-4ca4-6a34-08d951a5b8da",
                    "gcrId": "caaaac39-b1f4-4fee-d2d2-08d951a5b8b7",
                    "version": "9.0"
                }
            ],
            "[email protected]": "...?$skip=1"
        }
    ],
    "@odata.nextLink": "...$skip=1"
}

I ideally want that to be a different number is there a way to specify expand PageSize?

Many thanks Peter

p6345uk avatar Dec 07 '23 11:12 p6345uk

Please use the "Discussions" tab to ask questions in repositories that have that enabled in the future.

julealgon avatar Dec 07 '23 13:12 julealgon

I would say it is undesirable functionality. Which I would class as a bug. Updated the title @julealgon

As it applies the PageSize to the nested Expands.

I'm not seeing a way to override or modify or disable it for the expands.

Looks like this is similar to #1041

p6345uk avatar Dec 07 '23 13:12 p6345uk

Did you try configuring the page size in the EDM model builder for each type instead of in the [EnableQuery] attribute @p6345uk ?

julealgon avatar Dec 07 '23 17:12 julealgon

yes

[Page(MaxTop = 30, PageSize = 5)]

I have this specified on my expand which works in isolation. However Adding [EnableQuery(PageSize = 1)] on the endpoint overrides this on the expand.

p6345uk avatar Dec 08 '23 09:12 p6345uk

What about not setting that PageSize on EnableQuery then @p6345uk ? Doesn't that give you the behavior you want?

BTW, I wasn't referring to the Page attribute when I said in the EDM model builder. I was talking about the place where you configure your EDM model (I'm assuming you are using an EDM model?).

julealgon avatar Dec 08 '23 11:12 julealgon

I Have tried setting that however

Something similar to builder.EntityType<T>().Page(maxTopValue, pageSizeValue);

It seems to just ignore it. Or it doesn't have the next links.

I think I'm going to try to extract the functionality and put together an example so you fully see what I'm doing

p6345uk avatar Dec 08 '23 14:12 p6345uk

@p6345uk any update? same issue for me. I have an entity with a child list, if I do an expand, the child list adds unwanted pagination(LIMIT in mysql).

ramiro-alegre avatar Mar 18 '24 19:03 ramiro-alegre

Yea no update. Not found any way round it yet

p6345uk avatar Mar 25 '24 22:03 p6345uk