我通過WCF服務獲取我的應用程序的數據。而在服務器端,服務使用EF4.1作爲數據訪問。 服務方法看起來有點像這樣:WCF/EF 4.1的問題懶惰加載
public List<JobOffer> GetAllJobOffers()
{
var allJobOffers = _jobOffersRepository.GetAll().ToList();
return allJobOffers;
}
,倉庫在完成這樣
public override IQueryable<JobOffer>GetAll()
{
return _context.JobOffers.Include(c => c.Company);
}
我得到這個奇怪的錯誤:
An error occurred while receiving the HTTP response to http://localhost:8080/JobsService/ws . This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
在調試模式後擊中F5它開始永久循環。
在我的情況下,它應該在服務器端延遲加載一些問題。因爲當我調用服務來返回具有簡單結構的對象時,它就像一個冠軍。什麼可能會搞砸了?用EF快速加載對象的最佳做法是什麼?
所以你說沒有辦法通過電線發送整個對象樹? – 2011-05-13 19:15:09
有一種方法,但您必須幫助WCF序列化實體。這裏有你所有的選擇:http://stackoverflow.com/questions/5762135/ef4-cause-circular-reference-in-web-service/5763627#5763627 – 2011-05-13 19:54:18
非常感謝。 EF幫助我解決了大部分問題! – 2011-05-13 20:15:35