You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to get entity url?

GetDocumentUrl is a method in Advanced session operations that returns full url for a given entity.

Syntax

string GetDocumentUrl(object entity);

Parameters
entity object Instance of an entity for which url will be returned.
Return Value
string Full url for a given entity.

Example

Employee employee = session.Load<Employee>("employees/1");
// http://localhost:8080/databases/Northwind/docs/employees/1
string url = session.Advanced.GetDocumentUrl(employee);

Remarks

If the entity is transient (not attached) this method will throw InvalidOperationException.