|
| 1 | +# Core Types |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Types exist in graph which are highly-connected/central to the graph ecosystem. Often, these types are the position of containing many structural properties relevant to other APIs, because they are connected to many entities in the graph. |
| 6 | + |
| 7 | +Structural properties should be only added to these core types when they are properties of the entity itself and strictly not for the purpose of convenience due to the entity's position in the graph. |
| 8 | + |
| 9 | +## Core Types in Graph |
| 10 | + |
| 11 | +The following types are identified as core types, and will require strong justification to allow new structural properties to be added in all cases. |
| 12 | + |
| 13 | +- ```user``` |
| 14 | +- ```group``` |
| 15 | +- ```device``` |
| 16 | + |
| 17 | +## Alternatives to Adding Structural Properties |
| 18 | + |
| 19 | +Instead of adding a structural property to an existing type, do the following: |
| 20 | +1. Create a new type that models the information captured in the proposed structural property. |
| 21 | +2. Create a navigation property linking the new type to the existing type, doing one of the following: |
| 22 | + - Contain the new type in an entity set elsewhere, and add a navigation property to the existing type on the new type. |
| 23 | + - Contain the new type in an entity set elsewhere, and add a navigation property to the new type on the existing type. |
| 24 | + - Add a navigation property to the new type on the existing type, containing the new type. |
| 25 | + |
| 26 | +## Example: |
| 27 | + |
| 28 | +Modeling adding "bank account information", which includes two properties `accountNumber` and `routingNumber`, to entity type ```user```. |
| 29 | + |
| 30 | +### Don't: |
| 31 | + |
| 32 | +Don't add new properties to core types such as `user`. |
| 33 | + |
| 34 | +```xml |
| 35 | +<EntityType name="user"> |
| 36 | + <Property Name="accountNumber" Type="Edm.string"/> |
| 37 | + <Property Name="routingNumber" Type="Edm.string"/> |
| 38 | +</EntityType> |
| 39 | +``` |
| 40 | + |
| 41 | +### Do: |
| 42 | + |
| 43 | +Instead, create a new entity modeling the concept that you wish to introduce, and create a navigation property connecting that entity to the desired type. |
| 44 | + |
| 45 | +```xml |
| 46 | +<EntityType name="bankAccountInformation"> |
| 47 | + <Property Name="accountNumber" Type="Edm.string"/> |
| 48 | + <Property Name="routingNumber" Type="Edm.string"/> |
| 49 | +</EntityType> |
| 50 | + |
| 51 | +... |
| 52 | + |
| 53 | +<EntityType name="user"> |
| 54 | + <NavigationProperty Name="bankAccountInformation" Type="bankAccountInformation" ContainsTarget="true"/> |
| 55 | +</EntityType> |
| 56 | +``` |
0 commit comments