@@ -146,6 +146,7 @@ static bool IsActionOrFunction( IEdmEntitySet? entitySet, IEdmSingleton? singlet
146
146
}
147
147
148
148
const string ActionMethod = "Post" ;
149
+ const string AddNavigationLink = ActionMethod + "To" ;
149
150
const string FunctionMethod = "Get" ;
150
151
151
152
if ( ActionMethod . Equals ( method , OrdinalIgnoreCase ) && actionName != ActionMethod )
@@ -156,7 +157,7 @@ static bool IsActionOrFunction( IEdmEntitySet? entitySet, IEdmSingleton? singlet
156
157
return false ;
157
158
}
158
159
159
- return ! IsNavigationPropertyLink ( entitySet , singleton , actionName , ActionMethod ) ;
160
+ return ! IsNavigationPropertyLink ( entitySet , singleton , actionName , ActionMethod , AddNavigationLink ) ;
160
161
}
161
162
else if ( FunctionMethod . Equals ( method , OrdinalIgnoreCase ) && actionName != FunctionMethod )
162
163
{
@@ -172,7 +173,7 @@ static bool IsActionOrFunction( IEdmEntitySet? entitySet, IEdmSingleton? singlet
172
173
return false ;
173
174
}
174
175
175
- static bool IsNavigationPropertyLink ( IEdmEntitySet ? entitySet , IEdmSingleton ? singleton , string actionName , string method )
176
+ static bool IsNavigationPropertyLink ( IEdmEntitySet ? entitySet , IEdmSingleton ? singleton , string actionName , params string [ ] methods )
176
177
{
177
178
var entities = new List < IEdmEntityType > ( capacity : 2 ) ;
178
179
@@ -191,21 +192,52 @@ static bool IsNavigationPropertyLink( IEdmEntitySet? entitySet, IEdmSingleton? s
191
192
}
192
193
}
193
194
195
+ var propertyNames = default ( List < string > ) ;
196
+
194
197
for ( var i = 0 ; i < entities . Count ; i ++ )
195
198
{
196
199
var entity = entities [ i ] ;
197
200
198
- if ( actionName == ( method + entity . Name ) )
201
+ for ( var j = 0 ; j < methods . Length ; j ++ )
199
202
{
200
- return true ;
201
- }
203
+ var method = methods [ j ] ;
202
204
203
- foreach ( var property in entity . NavigationProperties ( ) )
204
- {
205
- if ( actionName . StartsWith ( method + property . Name , OrdinalIgnoreCase ) )
205
+ if ( actionName == ( method + entity . Name ) )
206
206
{
207
207
return true ;
208
208
}
209
+
210
+ if ( j == 0 )
211
+ {
212
+ if ( propertyNames is null )
213
+ {
214
+ propertyNames = new ( ) ;
215
+ }
216
+ else
217
+ {
218
+ propertyNames . Clear ( ) ;
219
+ }
220
+
221
+ foreach ( var property in entity . NavigationProperties ( ) )
222
+ {
223
+ if ( actionName . StartsWith ( method + property . Name , OrdinalIgnoreCase ) )
224
+ {
225
+ return true ;
226
+ }
227
+
228
+ propertyNames . Add ( property . Name ) ;
229
+ }
230
+ }
231
+ else if ( propertyNames is not null )
232
+ {
233
+ for ( var k = 0 ; k < propertyNames . Count ; k ++ )
234
+ {
235
+ if ( actionName . StartsWith ( method + propertyNames [ k ] , OrdinalIgnoreCase ) )
236
+ {
237
+ return true ;
238
+ }
239
+ }
240
+ }
209
241
}
210
242
}
211
243
0 commit comments