Im using umbraco v 4.11.8 (Assembly version: 1.0.4869.17899)
My code looks like:
var news = Model.NodeById(1077);
var count = 1;
foreach(dynamic n in news.Descendants().Where("Visible").Where("NodeTypeAlias == \"Article\"").OrderBy("publishDate desc").OrderBy("CreateDate desc").Take(11))
{
var theNewsDate = @n.publishDate.ToString("d/M-yyyy");
You are absolutly right. I can see that the problem is the publishDate. It is our own field, and it can be Null. What we want is to order the recordset by the publishDate and then the CreateDate if the publishDate is null. It is possibel ??? Is there a way like in SQL where we can set the field equals somthing if it is null?
We have tried OrderBy("publishDate, CreateDate desc")
foreach (dynamic n in news.Descendants().Where("Visible").Where("NodeTypeAlias == \"Article\"").OrderBy("publishDate desc").OrderBy("CreateDate desc"))
Razor - Script error caused by too many items
Hello
I have a strange problem.
in my code i loop through my data set from umbraco.MacroEngines.DynamicNodeContext
If I select to many records ">250 i think) the page returns an error - no description. I have tried ?umbDebugShowTrace=true
Error loading MacroEngine script (file: articleArchive.cshtml)
Im using umbraco v 4.11.8 (Assembly version: 1.0.4869.17899)
My code looks like:
var news = Model.NodeById(1077);
var count = 1;
foreach(dynamic n in news.Descendants().Where("Visible").Where("NodeTypeAlias == \"Article\"").OrderBy("publishDate desc").OrderBy("CreateDate desc").Take(11))
{
var theNewsDate = @n.publishDate.ToString("d/M-yyyy");
...
Kind regards
/MIkael
Does the error also occur when you remove the ordering?
Hi
If I remove the .OrderBy("publishDate desc").OrderBy("CreateDate desc") i works?
Strange. Any ideas how to fix it?
Thanks.
I think that there is either a content node where a date is empty or you have mistyped the field names.
At least the "PublishDate" is not a property on the dynamic node. Try once to take "UpdateDate", just for testing purpose.
Hi Again
You are absolutly right. I can see that the problem is the publishDate. It is our own field, and it can be Null. What we want is to order the recordset by the publishDate and then the CreateDate if the publishDate is null. It is possibel ??? Is there a way like in SQL where we can set the field equals somthing if it is null?
We have tried OrderBy("publishDate, CreateDate desc")
foreach (dynamic n in news.Descendants().Where("Visible").Where("NodeTypeAlias == \"Article\"").OrderBy("publishDate desc").OrderBy("CreateDate desc"))
Thanks for your answer
/Mikael
is working on a reply...