You are currently browsing legacy 3.5 version of documentation. Click here to switch to the newest 5.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to get entity metadata?

When document is downloaded from server it contains various metadata information e.g. Id or current etag. This information is stored in session and available for each entity using GetMetadataFor method from Advanced session operations.


RavenJObject GetMetadataFor<T>(T instance);
instance T Instance of an entity for which metadata will be returned.
Return Value
RavenJObject Returns entity metadata. If the instance is transient it will load document from server and attach entity and its metadata to session.


Employee employee = session.Load<Employee>("employees/1");
RavenJObject metadata = session.Advanced.GetMetadataFor(employee);