我不知道如何利用Linq和EF来进行这一询问。
Imagine I有三个表A、B和C。
A and B have a many-to-many relationship. B and C have a 1-to-many relationship.
我想从B处获得记录,包括C,但从A s Id中过滤。 我很容易从B处得到记录:
var result = Context.A.Where(x => x.Id.Equals(aId)).SelectMany(x => x.B);
但是,当我试图将C包括在内时,我不知道如何这样做:
//This doesn t work
var result = Context.A.Where(x => x.Id.Equals(aId)).SelectMany(x => x.B.Include("C"));
另外,我用无uck(相当于上述)来尝试:
//Not working
var result = (from a in Context.A.Where(x => x.Id.Equals(aId))
from b in a.B.Include("C")
select b);
感谢您的帮助。