I have a collection of articles in Umbraco 7 which span multiple years and wanted to write a simple LINQ query to get items for the current year:
var press = Model.Content.Children.Where(w => Convert.ToDateTime(w.GetPropertyValue("publicationDate")) >= new Date(1,1,2018));
This results in the error:
Delegate 'System.Func' does not take 1 arguments.
I'm contemplating just bunging the data in a list of T - unless someone can steer me in the right direction with filtering on Umbraco content nodes?
Thanks in advance.
I'm thinking something like this looks more "correct" to me, but it's untested. One thing to note is the way I make sure to get the property as DateTime directly from Umbraco. And also I figured comparing it to a DateTime instead of a Date might make a difference.
var press = Model.Content.Children.Where(w => w.GetPropertyValue<DateTime>("publicationDate") >= new DateTime(2018,1,1));