x First time here? Check out the FAQ

Come work for Umbraco - The Umbraco HQ are hiring Project managers, .NET developers and DevOps people!

  • Avatar266posts463karma

    Trying to use containsAny in Razor in 4.7

    Chad Rosenthal started this topic April 26, 2011 @ 10:54

    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 posted this reply June 23, 2011 @ 09:29

    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!

  • Avatar266posts463karma
    Comment with ID: 80904
    Chad Rosenthal posted this reply June 23, 2011 @ 09:50

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


  • William Chang posted this reply June 23, 2011 @ 10:22

    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.


  • Avatar266posts463karma
    Comment with ID: 81316
    Chad Rosenthal posted this reply June 27, 2011 @ 08:22

    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.

     


  • Avatar135posts301karma
    Comment with ID: 81822
    Gareth Evans posted this reply July 1, 2011 @ 01:21

    I will investigate this issue


  • Avatar568posts691karma
    Comment with ID: 84176
    Tom posted this reply July 21, 2011 @ 12:41

    Hi Chad,

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

     

    Cheers,

    Tom


  • Avatar135posts301karma
    Comment with ID: 84179
    Gareth Evans posted this reply July 21, 2011 @ 12:44

    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?


  • Avatar568posts691karma
    Comment with ID: 84180
    Tom posted this reply July 21, 2011 @ 12:46

    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


  • Avatar568posts691karma
    Comment with ID: 84181
    Tom posted this reply July 21, 2011 @ 12:46

    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..


  • Avatar135posts301karma
    Comment with ID: 84343
    Gareth Evans posted this reply July 22, 2011 @ 01:30

    Hi Tom

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

    Gareth


Please login or Sign up To post replies