Hi Oleg.
Basically you should query the GroupMembershipLink. To get the group information add Container.xxx in the Fields property. Similarly, add Member.xxx for the user information.
You could filter the required groups by a direct condition on the group id, or a filter query (using In operator). Both should be performed on the Container field. Surely, I have a sample for all of this:
EntityQuery
groupMemberShip = new EntityQuery
{
TypeName =
"GroupMembershipLink",
Fields =
new string[] { "Container.Name", "Member.Name" },
Where =
new Or
{
Conditions =
new Compare[]
{
new Compare
{
LeftExpression =
new FieldExpression {FieldName="Container"},
Operator =
Operator.Equal,
RightExpression =
new ConstantExpression {Value = new EntityId {TypeName="UserGroup", Value= "dd5ed193-1aa7-4151-b424-f757af66959b"}}
},
new Compare
{
LeftExpression =
new FieldExpression {FieldName = "Container"},
Operator =
Operator.In,
RightExpression =
new QueryExpression
{
Query =
new EntityQuery
{
TypeName =
"UserGroup",
Where =
new Compare
{
LeftExpression =
new FieldExpression {FieldName="Name"},
Operator =
Operator.Contains,
RightExpression =
new ConstantExpression {Value = "sub"}
}
}
}
}
}
}
};