gro*_*kky 5 c# entity-framework dbcontext entity-framework-core
我的 EF Core 实体:
public class Order {
public string Code { get; set; }
public ICollection<LineItem> LineItems { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我可以使用以下方法获取该属性的原始值Code:
context.Entry(myOrder).OriginalValues["Code"]
Run Code Online (Sandbox Code Playgroud)
但如果我尝试对LineItems导航集合属性进行此操作,则会抛出以下错误:
The property LineItems on entity type Order is being accessed using the 'Property' method, but is defined in the model as a navigation property. Use either the 'Reference' or 'Collection' method to access navigation properties.
该异常消息并不涉及我可以找到的方法。
那么如何获取导航集合属性的原始值呢?