Copied to clipboard

Flag this post as spam?

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


  • Paul Griffiths 370 posts 1021 karma points
    Feb 27, 2016 @ 12:40
    Paul Griffiths
    0

    Getting dropdown property value from descendant

    Hi All,

    Can someone please explain why this works. I want to retrieve all property listings where the proeprtyCategory value is set to 'To Let' in a drop down data type

    var propertiesToLet = Model.Content.Descendants("propertyListingPage").Where(x => x.GetPropertyValue<bool>("propertyCategory")).ToList().OrderBy("CreateDate desc");
    

    and this doesnt

    var propertiesToLet = Model.Content.Descendants("propertyListingPage").Where(x => x.GetPropertyValue<string>("propertyCategory == To Let")).ToList().OrderBy("CreateDate desc");
    

    enter image description here

    many thanks

    Paul

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 27, 2016 @ 13:14
    Jeavon Leopold
    100

    I think just a little syntax issue:

    var propertiesToLet = Model.Content.Descendants("propertyListingPage").Where(x => x.GetPropertyValue<string>("propertyCategory") == "To Let")).ToList().OrderBy("CreateDate desc");
    
  • M Jamil 7 posts 87 karma points notactivated
    May 31, 2022 @ 09:20
    M Jamil
    0

    Hi,

    Above example works for a single dropdown value, but if dropdown enabled with multiple choice then how to compare the value in the where clause?

  • Paul Griffiths 370 posts 1021 karma points
    Feb 27, 2016 @ 20:54
    Paul Griffiths
    0

    Hi Jeavon,

    Thanks for the response, sorry for the late reply ive been out all day.

    You are absolutely correct though, what you suggested works just fine.

    Thanks for you help

    Paul

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Feb 27, 2016 @ 20:56
    Jeavon Leopold
    1

    Great!

Please Sign in or register to post replies

Write your reply to:

Draft