class MyEntityA
{
public long IDEntityA;
public List<MyEntityB> lstEntityB;
}
class MyEntityB
{
public long IDEntityB;
public string Name;
}
public class Test
{
List<long> lstIDsEntitiesB;
public void TestAlvaroProblem()
{
List<MyEntityA> entitiesA = new List<MyEntityA>();
IEnumerable<MyEntityA> filteredOut = entitiesA.Where(a => a.lstEntityB
.Select(b => b.IDEntityB).Intersect(lstIDsEntitiesB).Any());
}
}
You should select entitiesA where lstEntityB's Ids intersect with lstIDsEntitiesB