Copied to clipboard

Flag this post as spam?

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


  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    Mar 28, 2012 @ 19:31
    Markus Johansson
    0

    Filter members based on a generic propery

     

    Hi!

    I want to get all members of from the umbraco members section that as a generic property set to a certain value. My current approach looks something like this:

    var members = (from member in umbraco.cms.businesslogic.member.Member.GetAllAsList()
                           where member.getProperty("yada").Value.ToString() == yada.ToString()
                           select member);

    I know that this will force that code to load all members into memory which is not a good idea. How would you solve this problem without talking directly to the database? Is that possible?


     

     

     

  • Rodion Novoselov 694 posts 859 karma points
    Mar 29, 2012 @ 08:25
    Rodion Novoselov
    0

    Hi. Afaik, there's no such API to do what youu want besides going to the DB directly (what isn't a good idea I think).

    Perhaps a solution could be to make Examine index properties you need and getting them by an Examine query straight from the index.

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 29, 2012 @ 08:34
    Hendy Racher
    0

    Hi Markus,

    Indexing the members in Lucene would be the fastest option, but there's also a helper method in uQuery to get members by an XPath expression (which internally does one DB hit) - would expect that to be quicker than instantiating every member object.

    HTH,

    Hendy

  • Markus Johansson 1936 posts 5864 karma points MVP 2x c-trib
    Mar 29, 2012 @ 08:42
    Markus Johansson
    0

    Thanks alot for the feedback!

    I'll have a look at the Lucene-solution and uQuery (qhich is great stuff!). My approach since I posted this was create my own "MemberExtended" class that inherits Member, and add method that doese almost the same thing as the "GetUsersAsList"-method. Not ideal, but i works and is very fast.

Please Sign in or register to post replies

Write your reply to:

Draft