Using custom type for the id property

那年仲夏 提交于 2019-12-21 18:03:55

问题


I got the following classes:

public class UserId
{
    public UserId(int id){
        //some validation
    }

   public override string ToString() {}
}

public class User
{
    public UserId Id {get;set;}
}

How can I configure nhibernate/fluentnhibernate to use that class. The column is an int.


回答1:


as Diego mentioned it is not nessesaryly a good idea

// UserMap
Id(m => m.Id).CustomType<UserIdUserType>();


class UserIdUserType : IUserType { ... }


来源:https://stackoverflow.com/questions/9444056/using-custom-type-for-the-id-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!