This should be straightforward but I'm not making any progress on this issue. I want to write a LINQ statement that returns a person matching a given ID and include a set of visits. That I can do. Now, I need to include only active visits, that is include the visit only if the IsActive flag is true. My query is included below. What am I doing wrong?
var inmate = this.db.Inmates.Where(p => p.Id == id).Include(p => p.Visits.Where(v => v.IsActive)).FirstOrDefault();
Update #1 - I also tried this statement:
var inmate = this.db.Inmates.Include(p => p.Visits).Where(p => p.Id == id && p.Visits.Any(v => v.IsActive)).FirstOrDefault();