2

In umbraco 7, I would like to count all members of a particular group. In the docs for MemberService there is the method...

.GetMembersByGroup(string role);

which it is possible to count on obviously...

.GetMembersByGroup(string role).Count();

...IF I want to kill the performance of the site...that is doing a select, loading all data for all members, and then counting them.

What I need is something like...

.CountMembersByGroup(string role);

... and I'm hoping that I'm just looking in the wrong place. Does such a thing exist/is it possible?

Paul
  • 9,409
  • 13
  • 64
  • 113
  • I'm afraid there's only a way to do this by member type, but unfortunately not by member group. – elolos Apr 08 '16 at 17:29

1 Answers1

3

No other way to do it that I know of. As @elolos mentions, you can do it by type, but not group. If you literally just want a list of groups and counts, you might be best off just writing your own SQL to do the query. The SQL Statement to get the raw data you need would be something like:

SELECT cmsMember.*, umbracoNode.text AS [groupName] FROM cmsMember
INNER JOIN cmsMember2MemberGroup ON cmsMember.nodeId = cmsMember2MemberGroup.Member
INNER JOIN umbracoNode ON cmsMember2MemberGroup.MemberGroup = umbracoNode.id

You can modify that to do counts etc.

Tim
  • 4,217
  • 1
  • 15
  • 21