var ts = Model.Content.Site().FirstChild("trainingSchedule").Children("trainingScheduleItem")
.Where(x => x.IsVisible())
.Where(x => x.GetPropertyValue("programKey").ToString() == pk)
.GroupBy(x => x.GetPropertyValue("grouping"))
.OrderBy(x => x.GetPropertyValue<DateTime>("startDate")); // This line is breaking the page - why?
This was created using the query builder tool - I added an additional .Where clause and the GroupBy and everything works great, until I add the .OrderBy. Now I'm getting the message:
CS1928: 'System.Linq.IGrouping<object,Umbraco.Core.Models.IPublishedContent>' does not contain a definition for 'GetPropertyValue' and the best extension method...
Can anyone tell me what I'm missing?
UPDATE:
Moved the OrderBy clause to above the GroupBy...
new and working code below. Took me 6+ hours to figure that out - maybe this will help someone else.
LINQ OrderBy breaking my page
This was created using the query builder tool - I added an additional .Where clause and the GroupBy and everything works great, until I add the .OrderBy. Now I'm getting the message:
Can anyone tell me what I'm missing?
UPDATE: Moved the OrderBy clause to above the GroupBy... new and working code below. Took me 6+ hours to figure that out - maybe this will help someone else.
The error gave it away. You where execting IPublishedContent where you were getting IGrouping
I always break up complex queries like this one in variables. That way you get a error in visual studio because the type doesn't match.
is working on a reply...