Been looking for a solution for this but haven\'t been able to find one so far.
I\'m fairly sure its possible with one linq call but having trouble working it out.>
I was going to use a GroupJoin, but this should satisfy your requirement.
var query = dataContext.YourTable.Where(x => x.ValidFlag == 1 && (x.ParentId == null || dataContext.YourTable.Where( y => y.ParentId == x.Id) .First().ValidFlag == 1)) .ToList(); .