You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.
Session: How to Check if Entity has Changed
To check if a specific entity differs from the one downloaded from server, the HasChanged
method from the Advanced
session operations can be used.
Syntax
bool HasChanged(object entity);
Parameters | ||
---|---|---|
entity | object | Instance of entity for which changes will be checked. |
Return Value | |
---|---|
bool | Indicated if given entity has changed. |
Example
Employee employee = session.Load<Employee>("employees/1-A");
bool hasChanged = session.Advanced.HasChanged(employee); // false
employee.LastName = "Shmoe";
hasChanged = session.Advanced.HasChanged(employee); // true