Reputation: 381
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
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