我正在执行以下 LINQ 查询,该查询有效但不返回导航属性 Person 填充,我得到null.
public IEnumerable<SharePeople> GetSharePeopeByCarId(int carId)
{
return from q in _context.Cars
join s in _context.Shares
on q.CarId equals s.Car.CarId
join p in _context.SharePeople.Include(p => p.Person)
on s.ShareId equals p.ShareId
where q.CarId == carId
select p;
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,因为当我使用常规扩展方法_context.SharePeople.Include(p => p.Person)时。