Get Max for a DateTime attribute

17 views
Skip to first unread message

Sven

unread,
Mar 28, 2017, 8:50:26 AM3/28/17
to RavenDB - 2nd generation document database

Hi,

I have several types of entities in my database, e.g. "Customer" or "Item". Most of those entities have a "ModifiedOn" property with a DateTime value. I can't figure out, how to query the maximum ModifiedOn for each type of entity. The question I need to answer is: What is the highest ModifiedOn value in the database for Entity "Customer". Any help appreciated.

Regards

Sven

Oren Eini (Ayende Rahien)

unread,
Mar 28, 2017, 8:54:32 AM3/28/17
to ravendb
session.Query<Customer>()
  .OrderByDescending(c=>c.ModifiedOn)
  .Select(c=>c.ModifiedOn)
  .FirstOrDefault();

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sven

unread,
Mar 28, 2017, 10:40:27 AM3/28/17
to RavenDB - 2nd generation document database
Thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages