Copied to clipboard

Flag this post as spam?

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


  • James Taylor 14 posts 124 karma points
    Mar 07, 2017 @ 12:49
    James Taylor
    0

    Razor query - "does not contain"

    Hi All,

    How would I construct a query to exclude nodes which have a property equal to a particular string?

    I can include only those by using the following:

    .Where(x => x.GetProperty<String>("myCategory").Contains(myString))
    

    Basically, what's the opposite of this? Or, is there an .Excludes() or similar?

    Thanks.

  • David Peck 687 posts 1863 karma points c-trib
    Mar 07, 2017 @ 13:13
    David Peck
    100

    Just:

    .Where(x => x.GetProperty<String>("myCategory").Contains(myString) == false)
    
  • James Taylor 14 posts 124 karma points
    Mar 07, 2017 @ 13:15
    James Taylor
    0

    Many thanks, David!

  • Michael Latouche 504 posts 819 karma points MVP 3x c-trib
    Mar 07, 2017 @ 14:45
    Michael Latouche
    0

    Or even this should work:

    .Where(x => !x.GetProperty<String>("myCategory").Contains(myString))
    
Please Sign in or register to post replies

Write your reply to:

Draft