有没有一种方法可以在 Entity Framework 中填充对象的导航属性,同时通过传递对象的主键来加载对象本身?
可以说:
context.Request.LoadUsingPk(pk).LoadNavigationPropertiesRelatedToThisRequest
最佳答案
是 - 对于预先加载,您可以添加 Include()
调用 ( MSDN ):
context.Request.Include( request => request.NavigationProperty )...
这是一个扩展方法,因此您必须添加一个 using 使其可见:
using System.Data.Entity;
这里有一篇关于它的 MSDN 文章:Entity Framework - Loading Related Entities
关于c# - 在 Entity Framework 中填充导航属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15910906/