Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mikael Klante 3 posts 23 karma points
    May 24, 2013 @ 08:53
    Mikael Klante
    0

    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

     

     

     

  • Andreas Iseli 150 posts 427 karma points
    May 27, 2013 @ 10:09
    Andreas Iseli
    0

    Does the error also occur when you remove the ordering?

  • Mikael Klante 3 posts 23 karma points
    May 27, 2013 @ 10:34
    Mikael Klante
    0

    Hi

    If I remove the .OrderBy("publishDate desc").OrderBy("CreateDate desc") i works?

    Strange. Any ideas how to fix it?

    Thanks.

     


  • Andreas Iseli 150 posts 427 karma points
    May 27, 2013 @ 10:42
    Andreas Iseli
    0

    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.

  • Mikael Klante 3 posts 23 karma points
    May 27, 2013 @ 11:19
    Mikael Klante
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft