0

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

user2963570
  • 381
  • 6
  • 21

1 Answers1

1

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.

Robert Foster
  • 2,317
  • 18
  • 28