I get the error :
A cycle was detected in a LINQ expression.
in ToList() while trying to do the following:
Of course there is a cycle. You are using entityIds in the Where Linq Extension method and it is the query being constructed itself. Instead of modifying the inputted IEnumerable, return a new query as follows:
private IEnumerable FilterIdsByClient(IEnumerable entityIds)
{
var query =
MyObjectContext.CreateObjectSet()
.Where(x => x.ClientId == _clientId)
.Where(x => entityIds.Contains(x.Id))
.Select(x => x.Id);
return query.ToList();
}