开发者

NHibernate cascade update/insert

I have a Case class which exposes a Person object as follows:

public class Case
{
  public virtual Person Deceased {get;set;}
}

I have a PersonalAsset class which also exposes a Person:

public class PersonalAsset
{
  public virtual Person Owner {get;set;}
}

Assuming I write the following code within an ISession:

Case case = new Case();
Person deceased = new Person();
case.Deceased = deceased;
PersonalAsset asset = new Person开发者_如何学JAVAalAsset();
asset.Owner = deceased;
session.SaveOrUpdate(case);

Is there any mapping configuration which will save the PersonalAsset automatically? Or do I need to call session.Save(asset) as well?

Thanks

David


Without a reference between them you would need to save things manually. From a modeling point of view are you maybe missing an aggregate root that owns both of these things?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜