Copied to clipboard

Flag this post as spam?

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


  • Matt Taylor 873 posts 2086 karma points
    Jan 16, 2012 @ 18:43
    Matt Taylor
    1

    Best way to list members with a particular property value?

    I need to write a little .Net code that will return a list of members based on a member property value.

    I've added a new 'Date Picker' property to a member type called 'Expiry Date' and all the members will have this property set.

    What is the best way to get a list of all the members where the value of this property is in the past using the API?

    Regards,

    Matt

  • Matt Taylor 873 posts 2086 karma points
    Jan 17, 2012 @ 11:56
    Matt Taylor
    0

    Is there are way to get them in one hit rather than getting all members and then checking the property value of each?

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 17, 2012 @ 12:02
    Ismail Mayat
    1

    Matt,

    What version of umbraco are you using? If its later version then you can index the members into lucene index via examine then search that way. It will be lightening quick and much more efficient that getting all members then checking the expiry date field.

    Regards

    Ismail

  • Matt Taylor 873 posts 2086 karma points
    Jan 17, 2012 @ 12:10
    Matt Taylor
    0

    Hi Ismail,

    That's a good idea.
    I was thinking there would be a linq query I could use on umbraco.cms.businesslogic.member.Member.GetAllAsList().

    Seeing as there is already a member index set up I could use that.

  • Matt Taylor 873 posts 2086 karma points
    Jan 17, 2012 @ 18:48
    Matt Taylor
    0

    In case anyone does want to use the linq method then this sort of thing will do the trick.

    IEnumerable<Member> members = umbraco.cms.businesslogic.member.Member.GetAllAsList().Where(m => m.getProperty("subscriptionExpiryDate").Value.ToString() != "" && DateTime.Parse(m.getProperty("subscriptionExpiryDate").Value.ToString()) < DateTime.Now);

    But not as efficiently as using lucene.

    Regards,

    Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies