我通过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