Copied to clipboard

Flag this post as spam?

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


  • Boris 2 posts 22 karma points
    Nov 02, 2015 @ 14:10
    Boris
    0

    Sequence contains no elements in New Article preview macro

    Hello,

    I have a script that I basically copy pasted from an older Umbraco installation in a new one I am building. The macro takes my news articles and shows a list of article previews.

    This is the line where it is failing:

        @foreach (var page in Umbraco.Content(1269).Children.Where("Visible").OrderBy("date desc").Skip((pageNo - 1) * pageSize).Take(pageSize))
        {
            <article class="blogpost">
    

    When I try to re-use this code I get the following error:

    " Sequence contains no elements

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: Sequence contains no elements Source Error: Line 16: Line 17:

    Line 18: @foreach (var page in Umbraco.Content(1269).Children.Where("Visible").OrderBy("date desc").Skip((pageNo - 1) * pageSize).Take(pageSize)) Line 19: { Line 20:
    Source File: c:\Users\Administrator\Documents\My Web Sites\Views\MacroPartials\NewsArticleList.cshtml Line: 18 Stack Trace: [InvalidOperationException: Sequence contains no elements] System.Linq.Enumerable.First(IEnumerable1 source) +269 Umbraco.Web.Dynamics.DynamicQueryable.OrderBy(IQueryable source, String ordering, Func1 getDynamicListTypeCallback, Object[] values) +1120 Umbraco.Web.Dynamics.DynamicQueryable.OrderBy(IQueryable1 source, String ordering, Func1 getDynamicListTypeCallback, Object[] values) +89 Umbraco.Web.Models.DynamicPublishedContentList.OrderBy(String key) +181 Umbraco.Web.Models.DynamicPublishedContentList.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) +1392 CallSite.Target(Closure , CallSite , Object , String ) +220 "

    My articles are laid out in the same way as I've done it before.

    -News Page --News Article

    In both the content tree and document type tree.

    Any help?

    Thank you

Please Sign in or register to post replies

Write your reply to:

Draft