在正在查询EntitySet
(例如,多对多关系)的情况下,是否可以访问父对象?是否可以访问Linq对象的父级?
e.g
Thing thing = db.Things.First();
Widget widget = thing.Widgets.First();
// Let's assume that Widgets can have many things as well
// (i.e. widget.Things is possible)
widget.ParentThing // would return the same instance of thing used above
这可能吗?
所以当你尝试它发生了什么? –
不,除非'Widget'具有对'thing'的引用(这是合乎逻辑的,我假定你已经排除了这一点)。 –
@JeroenVannevel在这种确切的情况下?没有。出于说明目的,“ParentThing”是一种组成财产。 – drewwyatt