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?
精彩评论