添加了子选择,现在可以接收... ObjectContext实例已被处置,无法再使用

时间:2019-04-16 17:16:19

标签: c# entity-framework objectcontext

将PackageItems列表添加到已经有效的此代码中,并抛出ObjectContext错误:

var ret = packages.Select(s => new Package
{
    PackageNumber = s.PackageNumber,
    PackageTotalValue = s.PackageTotalValue,
    PackageDate = s.PackageDate,
    PackageItems = s.Order.PackageItems.Select(i => new PackageItem
    {
        ItemID = i.ItemID,
        ItemDescription = i.ItemDescription,
        Quantity = i.Quantity,
        Cost = i.Cost
    }).ToList()  
}).ToArray();

0 个答案:

没有答案