问题
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