@@ -874,16 +874,10 @@ def nav(self, nav_property):
874874 association_info .name ,
875875 association_info .namespace )
876876
877- navigation_entity_set = None
878- for end in association_set .end_roles :
879- if association_set .end_by_entity_set (end .entity_set_name ).role == navigation_property .to_role .role :
880- navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name , association_info .namespace )
877+ end = association_set .end_by_role (navigation_property .to_role .role )
878+ navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name )
881879
882- if not navigation_entity_set :
883- raise PyODataException (f'No association set for role { navigation_property .to_role } ' )
884-
885- roles = navigation_property .association .end_roles
886- if all ((role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE for role in roles )):
880+ if navigation_property .to_role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE :
887881 return NavEntityProxy (self , nav_property , navigation_entity_set .entity_type , {})
888882
889883 return EntitySetProxy (
@@ -1349,17 +1343,10 @@ def nav(self, nav_property, key):
13491343 association_set = self ._service .schema .association_set_by_association (
13501344 association_info .name )
13511345
1352- navigation_entity_set = None
1353- for end in association_set .end_roles :
1354- if association_set .end_by_entity_set (end .entity_set_name ).role == navigation_property .to_role .role :
1355- navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name )
1356-
1357- if not navigation_entity_set :
1358- raise PyODataException (
1359- f'No association set for role { navigation_property .to_role } { association_set .end_roles } ' )
1346+ end = association_set .end_by_role (navigation_property .to_role .role )
1347+ navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name )
13601348
1361- roles = navigation_property .association .end_roles
1362- if all ((role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE for role in roles )):
1349+ if navigation_property .to_role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE :
13631350 return self ._get_nav_entity (key , nav_property , navigation_entity_set )
13641351
13651352 return EntitySetProxy (
0 commit comments