Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get last write date of a RavenDB document via C#

In the Raven Studio UI, when you look into a document you can read (on the right of the page) the last write date of the document.

I don't find any access via the client API in C# to this information. Do you know if it's possible ?

like image 854
Antoine Blanchet Avatar asked Dec 11 '11 23:12

Antoine Blanchet


1 Answers

The last modifed date is stored in the metadata of the document. You can access it like this:

var product = session.Load<Product>(1);
RavenJObject metadata = session.Advanced.GetMetadataFor(product);

// Get the last modified time stamp, which is known to be of type DateTime
DateTime lastModified = metadata.Value<DateTime>("Last-Modified");

See Working with document metadata for more information about RavenDB's metadata.

like image 164
Thomas Freudenberg Avatar answered Nov 18 '22 17:11

Thomas Freudenberg