@@ -135,48 +135,6 @@ public string GetPostAsyncMethod(OdcmProperty odcmProperty, string requestBody =
135135 return string.Empty;
136136}
137137
138- public string GetImplicitNavigationPropertyUrlSegment(OdcmSingleton singleton, OdcmProperty odcmProperty)
139- {
140- /****
141- To help the future dev in figuring this out, put a break point on the next executable line
142- with the condition odcmProperty.Name == "teachers". The CSDL in and entities mentioned in these
143- comments are an example of the use of this scenario.
144- ****/
145-
146- // (1) Check that there are NavigationPropertyBindings. If there aren't any, then we know this segment is
147- // the canonical path to the reference.
148- if (singleton.NavigationPropertyBindings.Count == 0)
149- {
150- return "/" + odcmProperty.Name;
151- }
152-
153- // (2) Get all of the keys that contain our target path name. The keys come from the Path attribute on a
154- // NavigationPropertyBinding. So if our target property (OdcmProperty.Name) is named 'teachers', then we need to only consider
155- // NavigationPropertyBinding paths that end with 'teachers'. The NavigationPropertyBindings are found in the Singleton that
156- // defines the EntitySet that contains this property. The NavigationPropertyBindings provide generation hints for how to
157- // reference non-contained entities that are defined within the same Singleton (this statement is conjecture). This generation
158- // hints is used to specify a reference URL for $ref call.
159- // Example: in this case, "teachers". This should be the end part of the BindingPath.
160-
161- IEnumerable<string> keys = singleton.NavigationPropertyBindings.Where(kvp => kvp.Key.EndsWith(odcmProperty.Name)).Select(kvp => kvp.Key);
162-
163- string bindingTarget;
164-
165- // The first assumption is that CSDL is added with a convention where the last path segment in NavigationPropertyBinding.Path
166- // is named consistently in a singleton so it doesn't matter what the preceding segments are.
167- // The second assumption is that if the last path is named consistently, the target will be consistent as well.
168- // These may turn out to be a weak assumption. We use this assumption since we can't determine a unique path
169- // for three or more segments since *RequestBuilder and *Request objects are generated per entity+navigation,
170- // and not [entity+navigation]*n --> across multiple navigations.
171- if (keys.Count() > 0 && singleton.NavigationPropertyBindings.TryGetValue(keys.First(), out bindingTarget))
172- {
173- // We found the target
174- return "/" + bindingTarget;
175- }
176- else
177- return "/" + odcmProperty.Name;
178- }
179-
180138public string GetPostAsyncMethodForReferencesRequest(OdcmProperty odcmProperty)
181139{
182140 var sanitizedPropertyName = odcmProperty.Projection.Type.Name.GetSanitizedPropertyName(odcmProperty.Name);
@@ -195,11 +153,7 @@ public string GetPostAsyncMethodForReferencesRequest(OdcmProperty odcmProperty)
195153 // NavigationPropertyBinding generation hint. If there is, then we need to use it for
196154 // creating the URL of a reference entity in a POST body.
197155 if (serviceNavigationProperty.GetType() == typeof(OdcmSingleton))
198- {
199- var singleton = (OdcmSingleton)serviceNavigationProperty;
200-
201- implicitNavigationProperty = GetImplicitNavigationPropertyUrlSegment(singleton, odcmProperty);
202- }
156+ implicitNavigationProperty = "/" + odcmProperty.GetImplicitPropertyName((OdcmSingleton)serviceNavigationProperty);
203157
204158 var stringBuilder = new StringBuilder();
205159
0 commit comments