0
说我的对象图的样子:如何急切地包括导航性能的子对象
User
=> Friends
=> Clicks
=> Urls
所以,当我打开一个用户,我也想eagirly加载导航属性朋友。而且我希望朋友对象能够轻松加载点击等。
使用代码我现在我只能为1级做到这一点:
public User GetUserById(int userId)
{
return Get(x => x.Id == userId, includeProperties: "Friends").FirstOrDeafult();
}
这可能吗?
- 我使用MVC 4.1
- 我目前使用的基于http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
怎么样设置排序依据为孩子他们加载时的集合?这可能吗? – loyalflow
@ user1361315:这不是直接可能的,只有一些解决方法:http://stackoverflow.com/questions/7522784/ef-4-1-code-first-how-to-order-navigation-properties-when-using -include和 - 或 – Slauma