Hi,
I'm trying to find the best practice for deleting a member from a collection that is nested within an aggregate. (DDD)
I have a Person class that contains an address collection. Inserts and Updates of addresses are successfully done through the Person class. I also want to delete an address through the Person class. If I just remove an address from the collection and call Session.Update(person) I get the following error:
Quote:
Cannot insert the value NULL into column 'PersonId', table 'PutTogether.dbo.PersonPhone'; column does not allow nulls. UPDATE fails.
The statement has been terminated.
The configuration for the Person on the Address is:
Code:
<many-to-one class="DomainModel.Person, DomainModel, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null" foreign-key="FK_PersonAddress_Person" name="Person">
<column name="PersonId" not-null="true" />
</many-to-one>
The configuration for the Addresses on the Person is:
Code:
<bag cascade="all" name="Addresses">
<key>
<column name="PersonId" />
</key>
<one-to-many class="DomainModel.PersonAddress, DomainModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bag>
Thanks for your time,
Mark