You are currently browsing legacy 5.0 version of documentation. Click here to switch to the newest 5.1 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Get Entity Last Modified

When a document is downloaded from the server it contains various metadata information, including the last modified date of the document.

Last modified date is stored within the metadata in session and is available for each entity using the GetLastModifiedFor method from the Advanced session operations.


DateTime? GetLastModifiedFor<T>(T instance);
instance T Instance of an entity for which the last modified date will be returned.
Return Value
DateTime? Returns the last modified date for an entity. Throws an exception if the instance is not tracked by the session.


Employee employee = session.Load<Employee>("employees/1-A");
DateTime? lastModified = session.Advanced.GetLastModifiedFor(employee);