我对使用 linq 从 db 检索的一些数据有疑问。当我尝试访问数据时,出现以下异常: System.ObjectDisposedException :ObjectContext 的实例已被删除,无法再次将其用于需要连接的操作。这是代码:
using (ProvaDbEntities DBEntities =
new ProvaDbEntities(Utilities.ToEntitiesConnectionString()))
{
ObjectQuery<site> sites = DBEntities.site;
IEnumerable<site> q = from site in sites
select site;
{
ObjectQuery<auction> auctions = DBEntities.auction;
IEnumerable<auction> q1 = from auction in auctions
where auction.site == this.Name
select auction;
IEnumerable<IAuction> res = q1.Cast<IAuction>();
return res;
}
}
catch(Exception e)
{
throw new UnavailableDbException("[GetAuctions]" + e.Message);
}
有人可以帮助我吗???坦克法比奥