Session: How to Refresh an Entity
To update an entity with the latest changes from the server, use the refresh
method from advanced
session operations.
Syntax
def refresh(self, entity: object) -> object: ...
Parameter | Type | Description |
---|---|---|
entity | object |
An entity that will be refreshed |
Example
employee = session.load("employees/1", Employee)
self.assertEquals("Doe", employee.last_name)
# LastName changed to "Shmoe"
session.advanced.refresh(employee)
self.assertEquals("Shmoe", employee.last_name)
Remarks
Refreshing a transient entity (not attached) or an entity that was deleted on server-side will result in a InvalidOperationException
.