Copied to clipboard

Flag this post as spam?

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


  • kristian schneider 187 posts 327 karma points
    Oct 05, 2010 @ 16:13
    kristian schneider
    0

    Accessing a newly created member via Member.GetAll() fails

    Hi.

    I have a situation where I create new umbraco members via the Member class:

     mem = Member.MakeNew(email, MemberType.GetByAlias("Member"), new User(0));

    mem.getProperty("firstname").Value = firstname;
    mem.getProperty("lastname").Value = lastname;
    mem.Email = email;
      mem.Save();

    Afterwards I search in all users via the the following code:

    var all = Member.GetAll;

    var result = (from m in all
    where ((string) m.getProperty("lastname").Value).ToLower() == searchstring
    select m).ToList();

    This does not work.

    I recall something about the properties need to be read before the database is contacted and the properties are populated.

    Any Ideas?

     

     

  • Stefan Kip 1606 posts 4098 karma points c-trib
    Oct 05, 2010 @ 16:25
    Stefan Kip
    0

    Weird, this works for me (same idea):

    Member member = Member.GetAll.FirstOrDefault(m => m.GetPropertyValue("socialService") == _selectedService.Name && m.GetPropertyValue("socialServiceGUID") == _selectedService.UniqueID.ToString() && m.GetPropertyValue("socialServiceUserID") == userData.UserID);
  • kristian schneider 187 posts 327 karma points
    Oct 05, 2010 @ 16:27
    kristian schneider
    0

    If I go to the umbraco administraion, find my newly created member and press "save" it works.

  • kristian schneider 187 posts 327 karma points
    Oct 06, 2010 @ 09:57
    kristian schneider
    0

    Stupid me. In my simplified example I did not show that I also had a "activated" property. And that property was not set by my code so it was allways null.

    And in my linq query I checked if it was null before I did the search and if it was null i did nothing

  • 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