I’ve got a list: User{name, groupname} and I’ve got a function AddGroupMemberstip that takes a list of users and a groupname. I need to split up the users based on their groupname, then feed this into this function.
e.g. I ideally would like to do
var groups = users.<SOME LINQ FUNCTION>(u => u.groupname);
foreach(var group in groups)
{
AddGroupMembership(users.value, users.key);
}
where users.value would be a IEnumerable<User> and users.key would be the groupname which they all share (for that subgroup).
Please can someone suggest something.
You are looking for
GroupBy:Each group
gis itself anIEnumerable<User>, so there is no.valueproperty access when passing the first parameter toAddGroupMembership.