Copied to clipboard

Flag this post as spam?

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


  • Tom 20 posts 61 karma points
    May 04, 2017 @ 17:40
    Tom
    0

    Query Builder filtering with custom fields

    I've upgraded to 7.6.0. Some of my query's don't work now, like this one:

    @{ var selection = CurrentPage.Children.Where("statusPercentage < 100"); }
    

    The statusPercentage is a slider. I've also tried the new Query Builder because the result differs a bit in syntax. The builder itself only gives me the standard fields, not the custom field like statusPercentage in my exemple. I added that myself:

    @{
        var selection = Model.Content.Site().Children("project")
                            .Where(x => x.IsVisible())
                            .Where(x => x.statusPercentage < 100);
    }
    

    But that also won't work.

    The second query that doesn't work is this one:

    var selection = root.Descendants("photosItem").Where("Gear.Contains(\"" + @CurrentPage.Id + "\")").Where("Visible").Random(5);
    

    The field "gear" is a multiple content picker. It should return all photosItem's with one of the pages in that 'multiple content picker'-field is the current page. I read about the EnablePropertyValueConverters-setting, but I prefer to use the new way instead of the legacy-method.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    May 04, 2017 @ 21:09
    Alex Skrypnyk
    100

    Hi Tom

    Did you try to rewrite your code to strongly typed? I mean avoid dynamics at all, look please at https://our.umbraco.org/documentation/reference/Common-Pitfalls/

    Thanks,

    Alex

  • Tom 20 posts 61 karma points
    May 05, 2017 @ 06:51
    Tom
    0

    Thanks. No, unfortunately not yet. Going to dig into the strongly typed thing.

    Too bad it isn't noted in the release notes or upgrade manual for this releases it'll break down (parts of) the dynamics-method. If I look at the trouble after upgrading (couldn't log in, change in property value converters, drop support for dynamics) I think this should be a major release (8.0).

Please Sign in or register to post replies

Write your reply to:

Draft