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 690 posts 1896 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 4x c-trib
    Mar 07, 2017 @ 14:45
    Michael Latouche
    0

    Or even this should work:

    .Where(x => !x.GetProperty<String>("myCategory").Contains(myString))
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies