Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Odata adaptor support "Patch" request with "$expand" query during CRUD operations?

I have a component with ODataAdaptor as a data source, now i would like to make a Patch request with $expand query like i make for GET request(since GET request openly supports $expand query). But i don't have an idea whether it is accepted or is there any other way i can look into to approach this issue?

Actual request: http://localhost:49807/odata/Orders(10249)

Expected request: http://localhost:49807/odata/Orders(10249)/?$expand=OrderDetail($select=CustomerID)

with $expand query in Patch request.

like image 461
Logesh Avatar asked Nov 06 '22 20:11

Logesh


1 Answers

You can't easily Patch to nested properties, this is well documented restriction. However if you want to patch a single object, and return a result with the expanded path you have suggested then there are two simple steps to achieve this:

  1. Add the [EnableQuery] attribute to your Patch endpoint method.
  2. Make sure your patch response returns an IQueryable result, or that you aggressively include / eager load all the potential expansions to your object response inside the method body, then the serializer will return the expanded object graph.
like image 159
Chris Schaller Avatar answered Nov 29 '22 09:11

Chris Schaller