实体框架可以通过 ID 自动更新属性导航吗
在实体框架中,当我通过设计器将表映射到相应的实体并开始实际使用它们时,我会发现一个实体 - Thing
,它具有关系(多对一)或一对一)与另一个对象(例如 Bob
)会在 Thing
上生成以下三个属性:
Bob
BobId
BobReference
如果我设置 BobId< /code>,并保存我的实体,下次我获取此
Thing
,我将能够毫无问题地导航 Bob
属性。不过,我很好奇是否可以配置 EF 以允许我导航属性而无需立即保存。
In Entity Framework, when I've mapped my tables to the corresponding entities through the designer and get to actually using them, I'll find that an entity - Thing
, who has a relationship (many to one, or one to one) with another object, say, Bob
, for example, would produce the following three properties on Thing
:
Bob
BobId
BobReference
And were I to set BobId
, and save my entity, the next time I fetch this Thing
, I'll be able to navigate the Bob
property without trouble. I'm curious, however, if it is possible to configure EF to allow me to navigate the property without having to immediately save.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以这样做:(EF 4.1)
然后 thing.Bob is != null
You can do something like this: (EF 4.1)
and then thing.Bob is != null