Mapping collections of elements and components

So far, we've shown how to use collections where an entity relates to a set of other entitities. However, a collection can also hold simple values, such as strings or components, that is, objects with properties but no id.

Getting ready

Complete the Getting ready instructions at the beginning of this chapter.

How to do it…

  1. Add a new folder named ComponentCollections to the MappingRecipes project.
  2. Add a new class named Customer to the folder:
    public class Customer { public Customer() { Addresses=new List<Address>(); Tags=new HashSet<string>(); } public virtual Guid Id { get; protected set; } public virtual string Name { get; set; } public virtual IList<Address> Addresses { get; set; } public virtual ISet<string> ...

Get NHibernate 4.x Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.