var nodes = Model.Descendants("saEvent").Where("eventStartDateTime <= DateTime.Now && eventEndDateTime >= DateTime.Now");
Which works fine but I'd like to be able to page through events by month which means I would have to pass in a month and year via the querystring but I'm not sure how to convert my document properties into month and year variables in the where clause.
What's the best way of tackling this issue, I'm assuming doing my filtering in the where clause will be faster than grabbing all the documents and looping over them.
If your properties are from datepickers than they are going to come through as DateTime objects, so something like this should work, for months at least:
var nodes = Model.Descendants("saEvent").Where("eventStartDateTime.Month <= DateTime.Now.Month && eventEndDateTime.Month >= DateTime.Now.AddMonths(1).Month");
Filter by month and year
Hi folks I currently have;
Which works fine but I'd like to be able to page through events by month which means I would have to pass in a month and year via the querystring but I'm not sure how to convert my document properties into month and year variables in the where clause.
What's the best way of tackling this issue, I'm assuming doing my filtering in the where clause will be faster than grabbing all the documents and looping over them.
Any help appreciated!
Thanks
Simon
Hey Simon,
If your properties are from datepickers than they are going to come through as DateTime objects, so something like this should work, for months at least:
Brilliant, it didn't occur to me I would have access to properties like .Month, thats just made my life a lot easier.
Cheers.
Simon
is working on a reply...