You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 11. Collections of structural types (complex types or primitive types)
321
+
322
+
Entity types are generally preferred for collections since complex types within a collection cannot be individually referenced. Collections of complex types, including any nested properties, must be updated as a single unit, entirely replacing the existing contents. Even if your API is read-only today, modeling it as a collection of entities gives you more flexibility in referencing individual members now and in the future.
323
+
Sometimes, structural collection properties are added to a type and then scenarios are discovered later that require a collection of entity types.
324
+
Take the following model with an entity type `application` that has a collection of `keyCredential`s:
Clients will now be able to refer to individual `keyCredential`s using `keyId` as a key, and they can now remove those `keyCredential`s using `DELETE` requests:
To maintain backwards compatibility **and** compliance with the OData standard, there are several semantic changes that the workload must address:
446
+
1. Existing clients would have been able to `$select` the `keyCredentials` property.
447
+
Now that `keyCredentials` is a navigation property, the [OData standard](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#_Toc31361040) specifies that its navigation link be returned when it is `$selected`:
448
+
449
+
> If the select item is a navigation property, then the corresponding navigation link is represented in the response.
450
+
451
+
Because the previous behavior for `$select=keyCredentials` was to include the collection in the response, and because the standard dictates that the navigation link be included in the response, the new behavior is to include both:
452
+
453
+
```http
454
+
GET /applications/{applicationId}?$select=keyCredentials
2. The default behavior for structural collections is to include them in the response payload for their containing entity. If this was the behavior of `application` before, it must be preserved by **auto-expanding** the `keyCredentials` property now that it is a navigation property (because the default behavior for navigation properties is to **not** expand them).
473
+
3. Structural collections can be updated using a `PATCH` request to the containing entity to replace the entire contents of the collection. If the service supported such updates to the structural collection, then updates to the new navigation property must preserve this behavior.
0 commit comments