4

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

Hans Preutz
  • 679
  • 2
  • 10
  • 28

1 Answers1

12

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

Morten OC
  • 1,784
  • 2
  • 23
  • 30