Skip to content

Commit de10274

Browse files
author
Caitlin Bales (MSFT)
committed
Add containment strategy connects to navigationproperty method
1 parent 562f2c0 commit de10274

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/GraphODataTemplateWriter/Extensions/OdcmModelExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,21 @@ public static IEnumerable<OdcmMethod> GetMethods(this OdcmModel model)
137137
return model.GetEntityTypes().SelectMany(entityType => entityType.Methods);
138138
}
139139

140+
/// <summary>
141+
/// Get the service collection navigation property for the given property type
142+
///
143+
/// We have revised the LINQ statement to support the following OData rules
144+
/// regarding containment:
145+
///
146+
/// 1. If a navigation property specifies "ContainsTarget='true'", it is self-contained.
147+
/// Generate a direct path to the item (ie "parent/child").
148+
/// 2. If a navigation property does not specify ContainsTarget but there is a defined EntitySet
149+
/// of the given type, it is a reference relationship. Generate a reference path to the item (ie "item/$ref").
150+
/// 3. If a navigation property does not have a defined EntitySet but there is a Singleton which has
151+
/// a self-contained reference to the given type, we can make a relationship to the implied EntitySet of
152+
/// the singleton. Generate a reference path to the item (ie "singleton/item/$ref").
153+
/// 4. If none of the above pertain to the navigation property, it should be treated as a metadata error.
154+
/// </summary>
140155
public static OdcmProperty GetServiceCollectionNavigationPropertyForPropertyType(this OdcmProperty odcmProperty)
141156
{
142157
// Try to find the first collection navigation property for the specified type directly on the service

0 commit comments

Comments
 (0)