I am stuck on filtering a returning collection with deeply nested objects with the the following code
var my collection = await myRepository.GetDBSet<MyObjectType>()
.include(x => Table1)
.include(x => Table2)
.include(x => Table2.Select(y => SubTable1))
.include(x => Table2.Select(y => SubTable1.Users))
.include(x => Table2.Select(y => SubTable1.Users.Addressess))
.include(x => Table2.Select(y => SubTable1.Users.Roles))
.include(x => Table2.Select(y => SubTable1.Users.Departments))
.Where(w => w.id1 = _id && w.isActive = t);
This example query works, please ignore the .where clause
I want to filter the SubTable1.Users.Departments and not bring back any departs with deptId != 1
Here is what I tried on the .where section
.Where(w => w.id1 = _id && w.isActive = t &&
w.Table2.where(s => s.SubTable1.Users.Departments.First().DeptId != 1))
This does not work, the error is saying it cannot convert int to bool. I had to add the .First() since it would not allow the DeptId. I am trying to filter out any dept record that has the deptId but not sure how to do this on a deeply nested linq statement.
Thanks in advance for any help.