OData / odata.net

ODataLib: Open Data Protocol - .NET Libraries and Frameworks
https://docs.microsoft.com/odata
Other
687 stars 349 forks source link

Support ordinalIndex for collection complex or primitive #3103

Open xuzhg opened 2 weeks ago

xuzhg commented 2 weeks ago

Short summary (3-5 sentences) describing the issue.

Assemblies affected

ordinalIndex = "/" 1*DIGIT

Reproduce steps

So, suppose we have a collection primitive value properties as "Emails"

we should support:

~/odata/customers(1)/emails/0 --> returns the first email or not found ~/odata/customers(1)/emails/1 --> returns the second or not found ~/odata/customers(1)/emails/-1 --> returns the last email or not found

So, suppose we have a collection complex value properties as "Locations"

we should support:

~/odata/customers(1)/Locations/0 --> returns the first location or not found ~/odata/customers(1)/Locations/1 --> returns the location or not found ~/odata/customers(1)/Locations/-1 --> returns the last location or not found

~/odata/customers(1)/Locations/{index}/city --> returns the city property of location which is located at {index} of Locations?

Expected result

What would happen if there wasn't a bug.

Actual result

What is actually happening.

Additional detail

Optional, details of the root cause if known. Delete this section if you have no additional details to add.

xuzhg commented 2 weeks ago

It's waiting customers' requirements. And there's a concern for the concurrency.

Suppose you get a item using the index, for example:

GET ~/odata/customers(1)/emails/2

then, some one deletes the third email using:

DELETE ~/odata/customers(1)/emails/2

Then, you use the original URI to fetch the third email is not the original email before the changes.

==> Design

1) Basically, to keep concurrency is based on end user business logic. The end user can only allow 'GET', but disallow to 'DELETE', 'PATCH' using the index on the collection. 2) From ODL perspective, ODL should allow parse the 'index' segment after collection. Then, the upper layer (the end user) can implement its logic based on the parsing result. Otherwise, the end user cannot benefit from it.

We can have more dicussion on it and looking forward more community feedbacks. @mikepizzo