views:

21

answers:

2

Given this (HORRIBLE) object graph that I can't change

public class Email
{
    public Email(string email) { ... }
    //DO a bunch of worthless stuff
}

public interface IPerson
{
    Email Email{get;set;}
}

Does something like this exist?

Map(p => p.EmailAddress).Use(s => new EmailAddress(s));

Essentially the Person interface won't take a string and I don't own the Email class so I can't modify it...

A: 

Not sure about Fluent NHibernate, but you can create your own IUserType which will map from Email to string and vice versa. It's real easy: see this for an example.

Anton Gogolev
A: 

It is called component and useful for mapping valuetypes like an emailaddress.

Paco