views:

22

answers:

1

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 PersonalAsset();
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

A: 

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?

ShaneC
I think your response may clarify the problem. I'm not quite sure which the aggregate is - it's either the case itself, or the deceased person.
David
I would strongly suspect that a person should contain a collection of assets.
ShaneC
@ShaneC is right. You aggregate root is Case, and a Person has many Assets.
Diego Mijelshon
You're correct that I needed a collection of assets with cascade enabled.
David