【发布时间】:2014-02-28 16:20:16
【问题描述】:
我使用服务堆栈作为我系统的 API,我使用实体框架从我的 SQL Server 数据库中获取数据。虽然,我无法从实体框架生成的对象列表中检索任何数据。
[Route("/getInterventions","GET")]
public class GetInterventions
{
}
public class GetInterventionsResponse
{
public List<Intervention> interventions { get; set; }
public ResponseStatus ResponseStatus { get; set; }
}
public class GetInterventionsService : Service
{
public object Any(GetInterventions request)
{
using (var dbConnection = new operationsContext())
{
List<Intervention> dbItems = dbConnection.Interventions.ToList();
return new GetInterventionsResponse{
interventions = dbItems
};
}
}
}
从客户端我得到:
ObjectContext 实例已被释放,不能再用于需要连接的“操作”(数据库名称)。
因此,有了这个错误,我可以验证问题是否与充当“虚拟”列表的列表有关,并且它的对象不会返回到客户端,而是作为引用或类似的东西传递。 那么我怎样才能深度复制这个列表并检索它的克隆呢?
还是谢谢
【问题讨论】:
标签: entity-framework list servicestack deep-copy