@@ -878,14 +878,40 @@ def nav(self, nav_property):
878878 navigation_entity_set = self ._service .schema .entity_set (end .entity_set_name )
879879
880880 if navigation_property .to_role .multiplicity != model .EndRole .MULTIPLICITY_ZERO_OR_MORE :
881- return NavEntityProxy ( self , nav_property , navigation_entity_set . entity_type , {} )
881+ return self . _get_nav_entity ( nav_property , navigation_entity_set )
882882
883883 return EntitySetProxy (
884884 self ._service ,
885885 self ._service .schema .entity_set (navigation_entity_set .name ),
886886 nav_property ,
887887 self ._entity_set .name + self ._entity_key .to_key_string ())
888888
889+ def _get_nav_entity (self , nav_property , navigation_entity_set ):
890+ """Get entity based on Navigation property name"""
891+
892+ def get_entity_handler (parent , nav_property , navigation_entity_set , response ):
893+ """Gets entity from HTTP response"""
894+
895+ if response .status_code != HTTP_CODE_OK :
896+ raise HttpError ('HTTP GET for Entity {0} failed with status code {1}'
897+ .format (self ._name , response .status_code ), response )
898+
899+ entity = response .json ()['d' ]
900+
901+ return NavEntityProxy (parent , nav_property , navigation_entity_set .entity_type , entity )
902+
903+ self ._logger .info (
904+ 'Getting the nav property %s of the entity %s for the key %s' ,
905+ nav_property ,
906+ self ._entity_set ,
907+ self .entity_key )
908+
909+ return NavEntityGetRequest (
910+ partial (get_entity_handler , self , nav_property , navigation_entity_set ),
911+ self .entity_key ,
912+ getattr (self ._service .entity_sets , self .entity_set .name ),
913+ nav_property )
914+
889915 def get_path (self ):
890916 """Returns this entity's relative path - e.g. EntitySet(KEY)"""
891917
0 commit comments