I am trying to convert my rest implementation to CSOM.
Rest API for the same : _api/web/sitegroups?$Filter=LoginName%20eq%20'Test_Grp'
Unable to find an equivalent for $filter
in lambda expressions.
I have a list of groupNames
and I need to fetch only those groups from SharePoint.
The below snippet throws a ClientRequestException
that
'The 'Contains' member cannot be used in the expression.
How can I retrieve only the groups whose names are in my list?
using (var clientContext = new ClientContext(ServerUrl))
{
GroupCollection collGroup = clientContext.Web.SiteGroups;
clientContext.Load(collGroup);
clientContext.Load(collGroup,
groups => groups.Include(
group => group.LoginName,
group => group.Title,
group => group.Id), group => group.Where(i => names.Contains((string)i.LoginName)));
clientContext.ExecuteQuery();
}