I have a working relationship with many (NOT bbidirectional), where the Resource has a set of many Allocations implanted, as shown below. A domain should do more with a collection of distributions that simply manage it with AddAllocation, RemoveAllocation, etc. Therefore, from the point of view of the object, I would like to add this additional logic, which is not constant, associated with another AllocationCollection class and make this additional class transparent to NHib.
I would also like to describe the capabilities of the AllocationCollection in a TDD manner, but I'm not sure how to refactor an existing class so that NHib still works, displaying the wise. How do you do this?
Cheers, Berryl
MODEL
public class Resource { public virtual ICollection<Allocation> Allocations { get { return _allocations ?? (_allocations = new HashSet<Allocation>()); } private set { _allocations = value; }
DISPLAY
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ... <class xmlns="urn:nhibernate-mapping-2.2" name="Domain.Model.Resources.Resource, ... table="Resources"> .... <set cascade="all-delete-orphan" name="Allocations"> <key foreign-key="Allocations_Resource_FK"> <column name="ResourceId" /> </key> <one-to-many class="Model.Allocations.Allocation, ... /> </set>
collections nhibernate nhibernate-mapping
Berryl
source share