Copied to clipboard

Flag this post as spam?

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


  • Stefan Bohlin 46 posts 168 karma points
    Jul 01, 2012 @ 01:15
    Stefan Bohlin
    0

    Search/Filter members by property

    Hi!

    A simple yet incredably hard question to find anwsers to:

    I'm making a search feature on my site and I would like users to filter the members on the site depending on some properties, so how do I filter members using razor?

    I'm going to have quite many members, so the search has to be able to handle a lot of members.

    Hope anyone has an anwser.

    Thanks

  • Yannick Smits 321 posts 718 karma points
    Jul 03, 2012 @ 19:37
    Yannick Smits
    0

    the last time I checked it couldn't been done. Had to fiddle with SQL queries.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Jul 03, 2012 @ 21:15
    Hendy Racher
    0

    Hi,

    How about querying the defulat InternalMember Lucene index via Examine ? or using an XPath expression to get the members via uQuery with uQuery.GetMembersByXPath(xpath);

  • Yannick Smits 321 posts 718 karma points
    Jul 03, 2012 @ 21:20
    Yannick Smits
    0

    Sounds good, would that perform?

  • Stefan Bohlin 46 posts 168 karma points
    Jul 04, 2012 @ 08:59
    Stefan Bohlin
    0

    I have been fiddling with this for some time, and i think i have succeeded.

    The trick seems to be to filter the members by Member Type first:

    var siteMembers = Member.GetAll.Where(x => x.ContentType.Alias == "MyUsers");

    Then I'm able to search the properties without running into errors like: Object doesn't contain bla bla bla...

    siteMembers =  siteMembers.Where(x => x.getProperty("age").Value.ToString().Contains(Request["age"]));

    I have not tested the speed on this with a large member base, but it does the trick for me :)

    Hope it helps anyone.

  • Yannick Smits 321 posts 718 karma points
    Jul 04, 2012 @ 12:36
    Yannick Smits
    0

    My experience is that as soon as you go through the umbraco membership api it gets to slow with 100+ members.

  • Nguyen Hien 52 posts 133 karma points
    Jan 19, 2016 @ 17:55
    Nguyen Hien
    0

    with umbraco 7.x you can use method

    GetMembersByPropertyValue("propertyalias", "value");

    Returns all Members, of any type, with a mathcing value in the property with the given property alias

Please Sign in or register to post replies

Write your reply to:

Draft