Session: How to get entity Id?

Entities does not have to contain Id property or field. In case of such an entity and a need of knowing under what Id it is stored on server GetDocumentId method has been created.


string GetDocumentId(object entity);
entity object Instance of an entity for which Id will be returned
Return Value
string Returns Id for specified entity. Method may return null if entity is null, isn't tracked or Id will be generated on the server.


public class Comment
	public string Author { get; set; }

	public string Message { get; set; }

string commentId = session
	.GetDocumentId(comment); // e.g. comments/1