Copied to clipboard

Flag this post as spam?

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


  • Doogie Talons 183 posts 318 karma points
    May 30, 2014 @ 13:34
    Doogie Talons
    0

    Help with syntax in contains element.

    Ok so I have a quick question.

    I will keep it brief incase it's simple :) 

     

    Why does this work...

    .Where("categorySelector.ToString().Contains(\"1096\")")

    and this doesnt...

    @{string AVariable ="1096";}

     

    .Where("categorySelector.ToString().Contains(AVariable)")

     

    I have tried...

    .Where("categorySelector.ToString().Contains(@AVariable)")

    .Where("categorySelector.ToString().Contains(\"AVariable"\)")

    .Where("categorySelector.ToString().Contains('AVariable')")

    For context the full statement is this

    @foreach (var page in progNode.Children.Where("visible").Where("documentTypeAlias == \"Programme\"").Where("categorySelector.ToString().Contains(\"1096\")").OrderBy("createDate desc"))

    So something 
    }

     

     

    Thanks :)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 31, 2014 @ 07:30
    Jeavon Leopold
    100

    Hi Doogie,

    You need to pass in the variable as a parameter, e.g

    @{string AVariable ="1096";}
    
    .Where("categorySelector.ToString().Contains(@0)",AVariable)
    

    Jeavon

  • Doogie Talons 183 posts 318 karma points
    May 31, 2014 @ 10:21
    Doogie Talons
    0

    Thanks for your help Jeavon it worked perfectly. :)

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    May 31, 2014 @ 11:33
    Jeavon Leopold
    0

    You're welcome :-)

Please Sign in or register to post replies

Write your reply to:

Draft