You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.2 version.
Session: How to check if entity has changed?
To check if specific entity differs from the one downloaded from server
HasChanged method from
Advanced session operations has been introduced.
bool HasChanged(object entity);
|entity||object||Instance of entity for which changes will be checked.|
|bool||Indicated if given entity has changed.|
Employee employee = session.Load<Employee>("employees/1"); bool hasChanged = session.Advanced.HasChanged(employee); // false employee.LastName = "Shmoe"; hasChanged = session.Advanced.HasChanged(employee); // true