Getting all users in one usergroup

Topics: General
Mar 25, 2011 at 5:49 PM

I have the name of a user group.

If I whant to get all users in this group, is there a funtion for that?


Mar 28, 2011 at 8:10 AM

If you mean C1 Console users/groups this should do it:

using System.Linq;
using Composite.Data;
using Composite.Data.Types;

// ...

    using (var dataConnection = new DataConnection())
        var users = from userGroup in dataConnection.Get<IUserGroup>()
                join relation in dataConnection.Get<IUserUserGroupRelation>()
                    on userGroup.Id equals relation.UserGroupId
                join user in dataConnection.Get<IUser>()
                    on relation.UserId equals user.Id
                where userGroup.Name == "Administrator" // name here
                select user;