Fluent NHibernate
Standard Mapping Components (Rev #1)

If you haven't setup a Fluent NHibernate project before, you should checkout the GettingStarted: Introduction guide.

As mentioned in ClassMap, all mappings are done from inside the constructor of a ClassMap<T> derived class; so baring that in mind, all examples are going to exclude the surrounding class.

Simple component

// schema
AddressNumber int
AddressStreet varchar(100)

// model
public Address Address { get; set; }

public class Address
{
  public int Number { get; set; }
  public string Street { get; set; }
}

// mapping
Component(x => x.Address, c =>
{
  c.Map(x => x.Number);
  c.Map(x => x.Street);
});

In this example, the first lambda (x) is used for specifying which property on your model is a component, and the second lambda (c) is used for actually defining what the component is. When you're working inside the second lambda, it's very similar to the Standard Mapping Class Map.