@@ -179,7 +179,9 @@ s is ODataOperationSegment ||
179179 {
180180 items . Add ( navPropSegment . NavigationProperty . Name ) ;
181181 }
182- else if ( segment is ODataTypeCastSegment typeCastSegment && path . Kind == ODataPathKind . NavigationProperty )
182+ else if ( segment is ODataTypeCastSegment typeCastSegment
183+ && path . Kind != ODataPathKind . TypeCast // ex: ~/NavSource/NavProp/TypeCast
184+ && ! ( path . Kind == ODataPathKind . DollarCount && path . Segments . ElementAt ( path . Segments . Count - 2 ) ? . Kind == ODataSegmentKind . TypeCast ) ) // ex: ~/NavSource/NavProp/TypeCast/$count
183185 {
184186 // Only the last OData type cast segment identifier is added to the operation id
185187 items . Remove ( previousTypeCastSegmentId ) ;
@@ -352,28 +354,35 @@ internal static string GenerateODataTypeCastPathOperationIdPrefix(ODataPath path
352354 string listOrGet = includeListOrGetPrefix ? ( complexSegment . Property . Type . IsCollection ( ) ? "List" : "Get" ) : null ;
353355 operationId = GenerateComplexPropertyPathOperationId ( path , listOrGet ) ;
354356 }
355- else if ( secondLastSegment as ODataNavigationPropertySegment is not null || isIndexedCollValuedNavProp )
357+ else if ( secondLastSegment is ODataNavigationPropertySegment navPropSegment )
356358 {
357- string listOrGet = null ;
359+ string prefix = null ;
358360 if ( includeListOrGetPrefix )
359361 {
360- listOrGet = ! isIndexedCollValuedNavProp && ( secondLastSegment as ODataNavigationPropertySegment ) ? . NavigationProperty . TargetMultiplicity ( ) == EdmMultiplicity . Many ? "List" : "Get" ;
362+ prefix = navPropSegment ? . NavigationProperty . TargetMultiplicity ( ) == EdmMultiplicity . Many ? "List" : "Get" ;
361363 }
362364
363- operationId = GenerateNavigationPropertyPathOperationId ( path , listOrGet ) ;
365+ operationId = GenerateNavigationPropertyPathOperationId ( path , prefix ) ;
364366 }
365- else if ( secondLastSegment is ODataKeySegment keySegment && ! isIndexedCollValuedNavProp )
367+ else if ( secondLastSegment is ODataKeySegment keySegment )
366368 {
367- string entityTypeName = keySegment . EntityType . Name ;
368- string getPrefix = includeListOrGetPrefix ? "Get" : null ;
369- string operationName = $ "{ getPrefix } { Utils . UpperFirstChar ( entityTypeName ) } ";
370- if ( keySegment . IsAlternateKey )
371- {
372- string alternateKeyName = string . Join ( "" , keySegment . Identifier . Split ( ',' ) . Select ( static x => Utils . UpperFirstChar ( x ) ) ) ;
373- operationName = $ "{ operationName } By{ alternateKeyName } ";
369+ if ( isIndexedCollValuedNavProp )
370+ {
371+ operationId = GenerateNavigationPropertyPathOperationId ( path , "Get" ) ;
374372 }
375- operationId = ( entitySet != null ) ? entitySet . Name : singleton . Name ;
376- operationId += $ ".{ entityTypeName } .{ operationName } ";
373+ else
374+ {
375+ string entityTypeName = keySegment . EntityType . Name ;
376+ string getPrefix = includeListOrGetPrefix ? "Get" : null ;
377+ string operationName = $ "{ getPrefix } { Utils . UpperFirstChar ( entityTypeName ) } ";
378+ if ( keySegment . IsAlternateKey )
379+ {
380+ string alternateKeyName = string . Join ( "" , keySegment . Identifier . Split ( ',' ) . Select ( static x => Utils . UpperFirstChar ( x ) ) ) ;
381+ operationName = $ "{ operationName } By{ alternateKeyName } ";
382+ }
383+ operationId = ( entitySet != null ) ? entitySet . Name : singleton . Name ;
384+ operationId += $ ".{ entityTypeName } .{ operationName } ";
385+ }
377386 }
378387 else if ( secondLastSegment is ODataNavigationSourceSegment )
379388 {
0 commit comments