You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently NavigationProperty objects need to refer to an Entity class. Two classes referencing eachother does not work unless NavigationProperties are added after everything else. Should we support Entity refs as strings? How to get the Entity behind the string?
The text was updated successfully, but these errors were encountered:
It would be really helpful to be able to pass the Entity refs as strings.
In the meantime, a workaround might be to specify the NavigationProperties in the __new__ method. This makes for somewhat ugly code, but it solves the problem when entities or types aren't declared in advance (possibly due to referencing each other), but will be available when the class is instantiated.
For example:
classProductPart(Service.Entity):
__odata_type__='ODataTest.Objects.ProductPart'__odata_collection__='ProductParts'id=IntegerProperty('PartID', primary_key=True)
name=StringProperty('PartName')
size=DecimalProperty('Size')
product_id=IntegerProperty('ProductID')
def__new__(cls, *args, **kwargs):
cls.product=NavigationProperty('Product', ProductWithNavigation,
foreign_key=ProductPart.product_id)
returnsuper(ProductPart, cls).__new__(cls, *args, **kwargs)
# in Python 3 code, super(ProductPart, cls) can be simplified to super()```
Currently NavigationProperty objects need to refer to an Entity class. Two classes referencing eachother does not work unless NavigationProperties are added after everything else. Should we support Entity refs as strings? How to get the Entity behind the string?
The text was updated successfully, but these errors were encountered: