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
Copy file name to clipboardExpand all lines: Templates/CSharp/Base/CollectionRequest.Base.template.tt
+59-35Lines changed: 59 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
<# // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. #>
public string GetPostAsyncMethodForReferencesRequest(OdcmProperty odcmProperty)
138
+
public string GetImplicitNavigationPropertyUrlSegment(OdcmSingleton singleton, OdcmProperty odcmProperty)
137
139
{
138
-
var sanitizedPropertyName = odcmProperty.Projection.Type.Name.GetSanitizedPropertyName(odcmProperty.Name);
139
-
var propertyType = this.GetPropertyTypeName(odcmProperty);
140
+
// (1) Check that there are NavigationPropertyBindings. If there aren't any, then we know this segment of
141
+
// the canonical path to the reference.
142
+
if (singleton.NavigationPropertyBindings.Count == 0)
143
+
{
144
+
return "/" + odcmProperty.Name;
145
+
}
140
146
141
-
var templateWriterHost = (CustomT4Host)Host;
142
-
var templateWriter = (CodeWriterCSharp)templateWriterHost.CodeWriter;
147
+
// (2) Get all of the keys that contain our target path name. The keys come from the Path attribute on a
148
+
// NavigationPropertyBinding. So if our target property (OdcmProperty.Name) is named 'schools', then we need to only consider
149
+
// NavigationPropertyBinding paths that end with 'schools'. The NavigationPropertyBindings are found in the Singleton that
150
+
// defines the EntitySet that contains this property. The NavigationPropertyBindings provide generation hints for how to
151
+
// reference non-contained entities that are defined within the same Singleton (this statement is conjecture). This generation
152
+
// hints is used to specify a reference URL for $ref call.
143
153
144
-
var serviceNavigationProperty = odcmProperty.GetServiceCollectionNavigationPropertyForPropertyType();
145
-
if (serviceNavigationProperty == null)
146
-
return string.Empty;
147
-
148
-
//Append the singleton's navigation type to the @odata.id if relevant
149
-
var implicitNavigationProperty = string.Empty;
150
-
if (serviceNavigationProperty.GetType() == typeof(OdcmSingleton))
151
-
{
152
-
var singleton = (OdcmSingleton)serviceNavigationProperty;
154
+
// TODO DELETE: in this case, "teachers". This should be the end part of the BindingPath.
153
155
154
-
// (1) Get all of the keys (Binding Paths) that contain our target path name, in this case, "teachers". This should be the end part of the BindingPath.
0 commit comments