File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed
src/GraphODataTemplateWriter/Extensions Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 3434 {5F526973-F69E-4C26-B8AD-612590A17A9E} .Release| Any CPU .ActiveCfg = Release| Any CPU
3535 {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Debug| Any CPU .ActiveCfg = Debug| Any CPU
3636 {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Debug| Any CPU .Build .0 = Debug| Any CPU
37- {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Release| Any CPU .ActiveCfg = Release |Any CPU
38- {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Release| Any CPU .Build .0 = Release |Any CPU
37+ {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Release| Any CPU .ActiveCfg = Debug |Any CPU
38+ {2256EC8D-FD7E-4A49-B616-70755AFC9F6C} .Release| Any CPU .Build .0 = Debug |Any CPU
3939 EndGlobalSection
4040 GlobalSection (SolutionProperties ) = preSolution
4141 HideSolutionNode = FALSE
Original file line number Diff line number Diff line change @@ -143,10 +143,13 @@ public string GetPostAsyncMethodForReferencesRequest(OdcmProperty odcmProperty)
143143 if (serviceNavigationProperty == null)
144144 return string.Empty;
145145
146- //Append the singleton's navigation type to the @odata.id if relevant
147146 var implicitNavigationProperty = string.Empty;
147+
148+ // If the odcmProperty is a part of Singleton, then we need to determine whether there is a
149+ // NavigationPropertyBinding generation hint. If there is, then we need to use it for
150+ // creating the URL of a reference entity in a POST body.
148151 if (serviceNavigationProperty.GetType() == typeof(OdcmSingleton))
149- implicitNavigationProperty = "/" + odcmProperty.Name ;
152+ implicitNavigationProperty = "/" + odcmProperty.GetImplicitPropertyName((OdcmSingleton)serviceNavigationProperty) ;
150153
151154 var stringBuilder = new StringBuilder();
152155
Original file line number Diff line number Diff line change @@ -208,6 +208,21 @@ public static OdcmProperty GetServiceCollectionNavigationPropertyForPropertyType
208208 }
209209 }
210210
211+ public static string GetImplicitPropertyName ( this OdcmProperty property , OdcmSingleton singleton )
212+ {
213+ var implicitPropertyName = property . Name ;
214+ // Default behavior
215+ if ( singleton . NavigationPropertyBindings . Count ( ) > 0 )
216+ {
217+ var target = singleton . NavigationPropertyBindings . Where ( kv => kv . Key . EndsWith ( property . Name ) ) . Select ( kvp => kvp . Value ) . FirstOrDefault ( ) ;
218+ if ( target != null )
219+ {
220+ implicitPropertyName = target ;
221+ }
222+ }
223+ return implicitPropertyName ;
224+ }
225+
211226 public static IEnumerable < OdcmProperty > NavigationProperties ( this OdcmClass odcmClass )
212227 {
213228 return odcmClass . Properties . Where ( prop => prop . IsNavigation ( ) ) ;
You can’t perform that action at this time.
0 commit comments