我有一些模型:
public class RootEntity
{
public int Id {get; set;}
public virtual ICollection<AbstractEntity> CollectionA {get; set;}
}
public abstract class AbstractEntity
{
public int Id {get; set;}
}
public class DerivedEntityA : AbstractEntity
{
public virtual ICollection<AnotherType> CollectionB {get; set;}
}
public class DerivedEntityB : AbstractEntity
{
public string Name {get; set;}
}
上述模型的关系是这样的:
RootEntity ---> ICollection<AbstractEntity>
┗━━ DerivedEntityA ---> ICollection<AnotherType>
┗━━ DerivedEntityB
---> has a
┗━━ derived from
现在我想更新一个使用 GraphDiffRootEntity
命名的实体:rootEntity
context.UpdateGraph(rootEntity, map => map
.OwnedCollection(r => r.CollectionA, with => with
.OwnedCollection(de => de.CollectionB) // this doesn't work because 'de' doesn't have 'CollectionB'
)
);
那么如何正确更新呢?