How to get news of all the newsCenter merged into one and then sort according publishdate property, if the property is empty by updatedate? The end result I want is like this:
Beginning i want to use @Library.NodesById for merge all the newsCenter.Children into one,but a good person tell me @Library is part of the old Razor code and should not be used anymore, so I use Union instead, this is my partial views code:
var keywords = new List<string>();
keywords.Add("oneNewsCenter");
keywords.Add("otherNewsCenter");
var values = new Dictionary<string, object>();
values.Add("keywords", keywords);
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var newsCenters = homePage.Children.Where("Name.ContainsAny(keywords)", values);
var allNews = new Umbraco.Web.Models.DynamicPublishedContentList();
foreach (var news in newsCenters.Children)
{
allNews.Union(news);
}
allNews.OrderBy("I do not know how to write");
run this will get a error:
'Umbraco.Web.Models.DynamicPublishedContentList' has no applicable method named 'Union' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
how to fix this code or there is a better way to solve this problem?
How to solve this problem by using Union and OrderBy?
umbraco ver is 7.0.2, umbraco.config data like this:
How to get news of all the newsCenter merged into one and then sort according publishdate property, if the property is empty by updatedate? The end result I want is like this:
Beginning i want to use @Library.NodesById for merge all the newsCenter.Children into one,but a good person tell me @Library is part of the old Razor code and should not be used anymore, so I use Union instead, this is my partial views code:
run this will get a error:
'Umbraco.Web.Models.DynamicPublishedContentList' has no applicable method named 'Union' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
how to fix this code or there is a better way to solve this problem?
thanks in advance
is working on a reply...