Copied to clipboard

Flag this post as spam?

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


  • Chad Rosenthal 272 posts 474 karma points
    Apr 26, 2011 @ 22:54
    Chad Rosenthal
    0

    Trying to use containsAny in Razor in 4.7

    I'm trying to implmenent the ContainsAny feature in Razor (mentioned on http://umbraco.com/follow-us/blog-archive/2011/3/13/umbraco-razor-feature-walkthrough-part-5). Here is my code.

               var listOfKeywords = keywords.Split(' ').ToList<string>();

                var values = new Dictionary<string, object>();

                values.Add("keywords", listOfKeywords);

                listOfEvents = listOfEvents.Where("summary.ContainsAny(keywords)", values);

    I send a keyword of 'summary', which I know is in the 2 of the 3 articles that I have. The problem is that I always get a  "Sequence contains no matching element". I've replaced the ContainsAny with just Contains and added the keyword in there and it works great. Just not this.

    I know that Examine would be faster, but I'd doing a lot of other filters and I still might convert it at some point, but for now, this is the direction that I'm going.

  • William Chang 6 posts 26 karma points
    Jun 23, 2011 @ 21:29
    William Chang
    0

    I'm having the same issue. Please help?

     

    var qsFacetIngredients = (string)qsItems["ingredients"] ?? String.Empty;
    
    var aryFacetIngredients = BaseUtility.SplitClean(qsFacetIngredients, '|');
    
    var facetValues = new Dictionary();
    facetValues.Add("keywords", aryFacetIngredients);
    
    var cmsItems = Model.Children.Where("checkboxIngredients.ContainsAny(keywords)", facetValues);
    

     

    I can't use "Contains" because the filters are dynamically created by using "Ultimate Picker" data type. Thus, I need help getting the "ContainsAny" working for multiple filtering (aka facets) of food items.

    FYI, I'm new to Umbraco and I've been using Razor exclusive than XSLT.

    Thank you!
  • Chad Rosenthal 272 posts 474 karma points
    Jun 23, 2011 @ 21:50
    Chad Rosenthal
    0

    Yeah. Didn't get this to work and ending up going a different route. Good luck

  • William Chang 6 posts 26 karma points
    Jun 23, 2011 @ 22:22
    William Chang
    0

    If nobody can't resolve it, then it could be a bug in Umbraco 4.7.0

    Chad Rosenthal,
    If you think it's a bug, can you report the "ContainsAny" issue to Umbraco Issue Trackerhttp://umbraco.codeplex.com/workitem/list/basic

    Thank you.

  • Chad Rosenthal 272 posts 474 karma points
    Jun 27, 2011 @ 20:22
    Chad Rosenthal
    0

    Is it possible for you to create the bug report. It's been 2 months since I wrote the code and tested it....and don't remember any of the steps to write up an accurate bug report besides containsAny doesn't work.

     

  • Gareth Evans 140 posts 331 karma points c-trib
    Jul 01, 2011 @ 01:21
    Gareth Evans
    0

    I will investigate this issue

  • Tom 713 posts 954 karma points
    Jul 21, 2011 @ 00:41
    Tom
    0

    Hi Chad,

    Just wondering what you did as a workaround because I can't get it working at all..

     

    Cheers,

    Tom

  • Gareth Evans 140 posts 331 karma points c-trib
    Jul 21, 2011 @ 00:44
    Gareth Evans
    0

    Hi Tom

    I intend to investigate ContainsAny before the 4.7.1 beta is released

    Could you show me what isn't working for you?

  • Tom 713 posts 954 karma points
    Jul 21, 2011 @ 00:46
    Tom
    0

    Hi Gareth! I just posted a new topic here:

    http://our.umbraco.org/forum/developers/razor/22412-No-applicable-method-'ContainsAny'-exists-in-type-'String

  • Tom 713 posts 954 karma points
    Jul 21, 2011 @ 00:46
    Tom
    0

    Even if you'd be able to post the fix for just that feature I'd really appreciate it..

    I just can't get it to pick up and use the extension method..

  • Gareth Evans 140 posts 331 karma points c-trib
    Jul 22, 2011 @ 01:30
    Gareth Evans
    1

    Hi Tom

    I've just patched the support for this feature in the trunk, would you like to try an updated binary?

    Gareth

Please Sign in or register to post replies

Write your reply to:

Draft