-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite key entities PUT,PATCH URIs generated by OData Client do not follow key order #2598
Comments
@KaltrinI How do you use ODataClient to generate the OData request? I have the following tests: var container = new Container(new Uri("http://localhost:5298/odata"));
var aEntities1 = container.AEntities.Where(a => a.CId == 8 && a.AId == "a" && a.BId == "b"); // #1
var aEntities2 = container.AEntities.Where(a => a.CId == 8 && a.BId == "baba" && a.AId == "aa" ); // #2 ODataClient generates the following two requests based on the above two 'Where' clauses. It seems you have put different orders in "where" clause, it will generate different orders. I attached my test project. Hope it can help. |
@xuzhg -- However, I think the real issue is that when you try to update/delete one of the entities fetched from the above queries, OData Client generates a request that should be the canonical URL, based on the order of keys in the CSDL, but is not. |
@xuzhg this is the code I use to track an already existing entity
After this, I update some property values of the entity. Next step I call
What I am able to see while debugging, the That being said, it fails on Microsoft.OData.ODataException: Expected literal type token but found token '...' |
Short summary (3-5 sentences) describing the issue.
When an entity has a composite key, the URIs are generated for an update of the entity, following the update route pattern for named keys (ex. "AEntities(CPk1={keyPk1}, BPk2={keyPk2},APk3={keyPk3})") does not map the keys accordingly, rather it generates an URI (ex. "AEntities(APk3={keyPk3}, BPk2={keyPk2},CPk3={keyPk1})") which causes an exception because the third part of the key gets assigned to the first part.
Assemblies affected
OData .Net lib 7.x*
Reproduce steps
Create an ASP Web API, an OData Connected Service, and a Unit Test project (that can be used for integration testing).
The models are attached in the ZIP file. Create OData Controllers for the entities and define the custom URIs for HttpPut and HttpPatch following the above convention.
In the unit test project, try to update an entity of type AEntity using the OData Client.
Expected result
Actual result
Additional detail
I am working on a test project where all of this is set up. In the meantime, feel free to request more information about the bug if the description is not clear.
Models.zip
The text was updated successfully, but these errors were encountered: