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