Skip to content

Commit

Permalink
Advanced > OData: remove valuelist from snippet (#498)
Browse files Browse the repository at this point in the history
* remove valuelist from snippet

* Proposal for example with structured annotation

* Re-add the "tip" box

---------

Co-authored-by: Steffen Weinstock <[email protected]>
Co-authored-by: Ralf Handl <[email protected]>
  • Loading branch information
3 people authored Dec 19, 2023
1 parent 2dd50d7 commit 525474e
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions advanced/odata.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,22 +217,25 @@ OData defines a strict two-fold key structure composed of `@<Vocabulary>.<Term>`

```cds
@Common.Label: 'Customer'
@Common.ValueList: {
Label: 'Customers',
CollectionPath: 'Customers'
@UI.HeaderInfo: {
TypeName : 'Customer',
TypeNamePlural : 'Customers',
Title : { Value : name }
}
entity Customers { }
entity Customers { /* ... */ }
```

This is represented in CSN as follows:

```json
```jsonc
{"definitions":{
"Customers":{
"kind": "entity",
"@Common.Label": "Customer",
"@Common.ValueList.Label": "Customers",
"@Common.ValueList.CollectionPath": "Customers"
"@UI.HeaderInfo.TypeName": "Customer",
"@UI.HeaderInfo.TypeNamePlural": "Customers",
"@UI.HeaderInfo.Title.Value": {"=": "name"},
/* ... */
}
}}
```
Expand All @@ -242,17 +245,23 @@ And would render to EDMX as follows:
```xml
<Annotations Target="MyService.Customers">
<Annotation Term="Common.Label" String="Customer"/>
<Annotation Term="Common.ValueList">
<Record Type="Common.ValueListType">
<PropertyValue Property="Label" String="Customers"/>
<PropertyValue Property="CollectionPath" String="Customers"/>
<Annotation Term="UI.HeaderInfo">
<Record Type="UI.HeaderInfoType">
<PropertyValue Property="TypeName" String="Customer"/>
<PropertyValue Property="TypeNamePlural" String="Customers"/>
<PropertyValue Property="Title">
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="name"/>
</Record>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
```

::: tip
The value for `@Common.ValueList` is flattened to individual key-value pairs in CSN and 'restructured' to a record for OData exposure in EDMX.
The value for `@UI.HeaderInfo` is flattened to individual key-value pairs in CSN and 'restructured'
to a record for OData exposure in EDMX.
:::

For each annotated target definition in CSN, the rules for restructuring from CSN sources are:
Expand Down

0 comments on commit 525474e

Please sign in to comment.