user2963570
user2963570

Reputation: 381

Umbraco 7 - Query Umbraco Members - Performance

I made this function to fetch all the members with their custom properties. I was just wondering whether this is written performant or not. Are there any - performance wise - cleaner solutions? Or is it okay to work with?

 public List<DashboardMemberModel> GetAllMembers()
    {
        //Members
        var members = ApplicationContext.Services.MemberService.GetAllMembers();

        //Populate List<DashboardMemberModel> & Return
        return members.Select(member => new DashboardMemberModel
        {
            Id = member.Id, 
            FirstName = Umbraco.TypedMember(member.Id).GetPropertyValue("firstName").ToString(), 
            LastName = Umbraco.TypedMember(member.Id).GetPropertyValue("lastName").ToString(), 
            Company = Umbraco.TypedMember(member.Id).GetPropertyValue("companyName").ToString()
        }).OrderBy(member => member.Id).ToList();
    }

Kind regards

Upvotes: 0

Views: 311

Answers (1)

Robert Foster
Robert Foster

Reputation: 2316

You could use the Lucene index instead - this is what the MemberListView does. Read the code on GitHub here:

https://github.com/robertjf/umbMemberListView/blob/master/MemberListView/Helpers/MemberSearch.cs

You may also want to add additional attributes to the Member Index.

Upvotes: 1

Related Questions