views:

411

answers:

2
+1  A: 

There is some good information here: http://nhforge.org/blogs/nhibernate/archive/2008/09/06/a-fluent-interface-to-nhibernate-part-2-value-objects.aspx that seems to be what you are wanting to do.

In particular the Action method demonstrated in this sample:

public class EmployeeMap : ClassMap<Employee>
{
    private Action<ComponentPart<Address>> MapAddress(string columnPrefix)
    {
        return a =>
               {
                   a.Map(x => x.AddressLine1, columnPrefix + "AddressLine1");
                   a.Map(x => x.AddressLine2, columnPrefix + "AddressLine2");
                   a.Map(x => x.PostalCode, columnPrefix + "PostalCode");
                   a.Map(x => x.City, columnPrefix + "City");
                   a.Map(x => x.Country, columnPrefix + "Country");
               };
}

public EmployeeMap()
{
    Id(x => x.Id);
    Map(x => x.FirstName).CanNotBeNull().WithLengthOf(20);
    Map(x => x.LastName).CanNotBeNull().WithLengthOf(20);

    Component<Address>(x => x.HomeAddress, MapAddress("Home_"));
    Component<Address>(x => x.WorkAddress, MapAddress("Work_"));
}

}

cspirz
+1  A: 

There's nothing implicit. AutoMapping does it, but not regular mapping. I've created an issue so you can track the status of this.

James Gregory

related questions