Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Umbraco 7, how can i search for all members with a custom property?

I am using Umbraco 7 (C#).

Is there an easy way/method to search for all members with a custom property?

I know that there is an easy way to search for all members by the username by using the method

GetByUsername(string username) : returns IMember

And also for searcing by Email:

GetByEmail(string email) : returns IMember

Do you know of such a way to search by a property?

I have tried using the method ".Where" like so:

GetService().GetAllMembers().Cast<IMember>().Where("permalink=SOMESTRING").ToArray();

Unfortunatly there is an error, since i can't use the .Where() method here.

Any suggestions?

Thanks

like image 974
Hans Preutz Avatar asked Dec 15 '22 19:12

Hans Preutz


1 Answers

You could just use the build in function in MemberService.

From the doc:

Services.MemberService

.GetMembersByPropertyValue("city", "Horsens");
//Returns all Members, of any type, with a mathcing value in the property with the given property alias

http://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberService

like image 178
Morten OC Avatar answered May 12 '23 23:05

Morten OC