How to remove "@odata.navigationLink" from response after "$expand=entity" or "$expand=*"? #1074
Unanswered
AndriiLesiuk
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Unfortunately, we don't currently have a setting for conditionally writing the navigation link depending on whether or not the navigation property was expanded. The best way I can think of to implement this behavior would be to not set the followsConvention to false in the model but instead to override the resource serializer and explicitly set the navigation links for any non-expanded navigation properties. I believe that @xuzhg has some examples that show how to override the resource serializer to provide such custom behavior. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I implemented adding "@odata.navigationLink", with this:
https://github.com/OData/AspNetCoreOData/issues/1022
Everything works fine, @odata.navigationLink are generated for all nested entities.
But when I do the $expand command, I expect that after that the @odata.navigationLink will not be generated for the entity being expanded.
The same goes for $expand=* - I expect all @odata.navigationLinks to not be present in the response.
There will be only objects.
Expected:
https://localhost:7233/odata/TestEntity(1)
https://localhost:7233/odata/TestEntity(1)?$expand=nestedEntity
Actual:
https://localhost:7233/odata/TestEntity(1)
https://localhost:7233/odata/TestEntity(1)?$expand=nestedEntity
I would be grateful for any advice.
(Editing and deleting the response in the middleware is not suitable for me, because I will be working with huge amounts of data, and it will destroy my performance)
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions