Here is my entity structure:
My code to get the Courses with all child Tests:
var course = await Db.Courses.Include(x => x.Tests).FirstOrDefaultAsync(y => y.CourseId == id);
It includes all the child Tests related to the Courses. But I want to include all Tests that status is not deleted (IsDeleted = false
). To do that I have use this code:
var course = await Db.Courses.Include(x => x.Tests.Where(y=>!y.IsDeleted)).FirstOrDefaultAsync(y => y.CourseId == id);
But it doesn't exclude the deleted Tests. Can anybody tell me how I can exclude the deleted tests?