开发者

Fluent NHibernate delegate mapping Func

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 IPer开发者_如何学Goson
{
    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...


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜