我只能使用SP從數據庫加載我的實體。我可以通過導入功能加載成功客戶:EF4:使用SP加載導航屬性
Customer cust = context.GetCustomerById(customerId);
然後,我需要使用另一個SP加載cust.Orders集合:
IEnumerable<Order> cust_orders = context.GetOrdersByCustomerId(customerId);
我得到具有正確設置屬性與客戶相關的訂單列表已加載的Customer實例。當我嘗試做類似的事情時出現問題:
foreach(Order ord in cust.Orders)
{
Console.WriteLine(ord.Number); // "SELECT permission required ..." exception is thrown here
}
有沒有方法來加載訂單屬性而不觸發選擇?
什麼樣的實體,您使用的? 'EntityObject'還是POCO? ObjectContext API或DbCotnext API? – 2012-03-26 08:17:45
EntityObject和ObjectContext數據庫優先方法。 – user1291948 2012-03-27 03:48:45