Copied to clipboard

Flag this post as spam?

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


  • Maarten van Alebeek 7 posts 87 karma points
    Mar 14, 2016 @ 12:15
    Maarten van Alebeek
    0

    Get members by multiple property values

    Hello,

    I'm trying to make an overview of all members filtering on multiple properties.

    I have tried to use the memberService.GetMembersByPropertyValue() method, but this only allows you to filter on one property.

    What would be the best way to filter on multiple properties?

    Thanks in advance,

    Maarten

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Mar 14, 2016 @ 13:05
    Dave Woestenborghs
    101

    Hi Maarten,

    Are you using this in the frontend of your website or in the backoffice.

    If it is the frontend i wouldn't recommend using the member Service because this will query the database and will resort in performance issues.

    All member data is also stored in a lucene index so you could query that so you get optimal speed.

    This is some code we have for querying the member index based on a property and a value. This can be adapted for multiple properties.

     public static IEnumerable<int> GetMemberIdsWithPropertyUsingExamine(string property, string value)
            {
                var examineprovider = ExamineManager.Instance.SearchProviderCollection["InternalMemberSearcher"];
                if (examineprovider != null)
                {
                    var criteria = examineprovider.CreateSearchCriteria();
                    if (criteria != null)
                    {
                        var fields = new[] { property };
                        var operation = criteria.GroupedOr(fields, value).Compile();
                        var searchResults = examineprovider.Search(operation);
    
                        return searchResults.Select(x => x.Id);
                    }
                }
    
                return new List<int>();
            }
    

    Dave

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Mar 14, 2016 @ 13:15
    Jeroen Breuer
    1

    Hello,

    For now Dave his example is the best way. There is a feature request to support this: http://issues.umbraco.org/issue/U4-6368

    Jeroen

  • Maarten van Alebeek 7 posts 87 karma points
    Mar 15, 2016 @ 13:56
    Maarten van Alebeek
    0

    Hi Dave,

    Thanks for your reply, this helped me a lot.

    Maarten

Please Sign in or register to post replies

Write your reply to:

Draft