File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/Microsoft.AspNet.OData.Versioning.ApiExplorer/Description Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -162,15 +162,29 @@ string GetEntityKeySegment()
162
162
163
163
void TryAddEntityKeySegmentByConvention ( StringBuilder convention )
164
164
{
165
- var keys = Context . EntityKeys . ToArray ( ) ;
165
+ // REF: http://odata.github.io/WebApi/#13-06-KeyValueBinding
166
+ var entityKeys = Context . EntityKeys . ToArray ( ) ;
167
+ var parameterKeys = Context . ParameterDescriptions . Where ( p => p . Name . StartsWith ( ODataRouteConstants . Key , OrdinalIgnoreCase ) ) . ToArray ( ) ;
166
168
167
- if ( keys . Length != 1 || ! Context . ParameterDescriptions . Any ( p => ODataRouteConstants . Key . Equals ( p . Name , OrdinalIgnoreCase ) ) )
169
+ if ( entityKeys . Length == parameterKeys . Length )
168
170
{
169
171
return ;
170
172
}
171
173
172
174
convention . Append ( '(' ) ;
173
- ExpandParameterTemplate ( convention , keys [ 0 ] , ODataRouteConstants . Key ) ;
175
+
176
+ if ( entityKeys . Length == 1 )
177
+ {
178
+ ExpandParameterTemplate ( convention , entityKeys [ 0 ] , ODataRouteConstants . Key ) ;
179
+ }
180
+ else
181
+ {
182
+ for ( var i = 0 ; i < entityKeys . Length ; i ++ )
183
+ {
184
+ ExpandParameterTemplate ( convention , entityKeys [ i ] , parameterKeys [ i ] . Name ) ;
185
+ }
186
+ }
187
+
174
188
convention . Append ( ')' ) ;
175
189
}
176
190
You can’t perform that action at this time.
0 commit comments