我有一个包含两个子类列表的父类
public class Parent
{
...
public virtual ICollection<Foo> Foo{ get; set; }
public virtual ICollection<Bae> Bar{ get; set; }
}
public class Foo
{
...
public virtual Parent Parent{ get; set; }
}
public class Bar
{
...
public virtual Parent Parent{ get; set; }
}
映射是
public ParentMap()
{
...
HasMany(m => m.Foo).AsSet().Cascade.All();
HasMany(m => m.Bar).AsSet().Cascade.All();
}
public FooMap()
{
...
References(m => m.Parent);
}
public BarMap()
{
...
References(m => m.Parent);
}
每当我保存父对象时,我都会得到
INSERT Parent ...
INSERT Foo with Parent_id set to NULL
INSERT Bar with Parent_id set to NULL
UPDATE Foo set Parent_id to Parent id
UPDATE Bar set Parent_id to Parent id
除了设置关系Inverse
以避免额外更新之外,还有其他方法吗?