Copied to clipboard

Flag this post as spam?

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

  • Radek 6 posts 116 karma points
    20 days ago

    Filtering by dropdown value

    Why doesn't below code work?

    var childrenInCat = Model.Parent.Children.Where<BlogPost>(x => x.blogPostCategory = category);

    I get "Type IEnumerable is Defined in an assembly that is not reference.

    Top of the page reads:

    @inherits UmbracoViewPage<BlogPost>

    I am using the v8 compatible notation.

    I've tried to follow documentation by appears that the only overload for Where I can use is Where<>(), documentation shows all examples with Where()

    Really lost at this point.

  • Mario 80 posts 568 karma points c-trib
    20 days ago

    I guess you have tried removing the <BlogPost> part? That should be inferred from the Children type which is IEnumerable<IPublishedContent>. If you want to cast them to BlogPost you can do:

    Model.Parent.Children.Where(x => x.Id == 123).Select(x=> new BlogPost(x));

    If you want to filter the children by doctype you can do:

  • Radek 6 posts 116 karma points
    20 days ago

    Ok so this turned out to be some sort of .NET Visual Studio issue.

    I've Googled the exception what was showing up when debugging the page.

    you must add a reference to assembly 'netstandard, version=, culture=neutral, publickeytoken=cc7b13ffcd2ddd51'.

    Solution was to add following to Web.Config

            <add assembly="netstandard, Version=, Culture=neutral, 
Please Sign in or register to post replies

Write your reply to: