0

以下代码无法按预期工作。虽然item.ActiveEntries在处理上下文后更新和持续存在,user.ShoppingCart.Cart. 此外,这两个属性都定义为virtual List<CartEntry>

using (var context = new LocabalSqlContext())
{
    var user = Auth.GetUser(context);
    var item = context.Items.First();
    var entry = new CartEntry()
    {
        Item = item,
        Quantity = 3,
        LastRefresh = DateTime.Now
    };
    item.ActiveEntries.Add(entry);
    user.ShoppingCart.CartEntries.Add(entry);
}
4

0 回答 0