Copied to clipboard

Flag this post as spam?

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

  • Radek 11 posts 142 karma points
    Jun 06, 2019 @ 20:06

    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 125 posts 769 karma points c-trib
    Jun 06, 2019 @ 21:52

    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 11 posts 142 karma points
    Jun 07, 2019 @ 01:54

    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: