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…
- Add a new folder named
ComponentCollections
to theMappingRecipes
project. - 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> Tags { get; set; } }
- Add a new class named
Address
to the folder:public class Address { public string AddressLine1 { get; set; } public string AddressLine2...