为什么不包括有什么影响? [英] Why doesn't Include have any effect?
本文介绍了为什么不包括有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做下面的LINQ查询其中工程,但没有返回导航业者填补,我得到空
。
I am doing the following LINQ Query which works but doesn't return the navigation property Person filled, I get 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;
}
我不知道为什么,因为当我不喜欢 _context.SharePeople.Include常规扩展方法(P =&GT; p.Person)。
它的工作原理
推荐答案
使用STE福办法也没有工作,但它的变化,我能够把它的工作。
Using ste-fu approach it did not worked, but with a variation of it I was able to put it to work.
我想格特·阿诺德回答为什么它不工作,但因为我得到了它在这里工作是code:
I guess Gert Arnold answered why it does not work, but since I got it working here is the code:
VAR sharePeople = Context.SharePeople.Include(人);
返回sharePeople.Where(S = GT; s.Shares.Car.CarId == carId);
这篇关于为什么不包括有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文