Mapping custom types in NHibernate 3.2

I just started using NHibernate 3.2 with the new Conformist API, which used previous versions with Fluent a while back. The main material seems fine, but I'm currently struggling with trying to match a string to a custom type.

In this particular case, I have a row, which is a list of roles, separated by a comma, in a column of one of my tables. When I find out, I want it to be mapped to a custom RoleSet object that I created by passing a string value from the database to its constructor.

I created IUserType but cannot figure out how to use it.

Earlier with Fluent, I would do this in my map class:

Map(x => x.Roles).CustomType<RoleSetType>(); 

Is there an equivalent way to do this in the new API?

+4
source share
1 answer

Try to try ...

 Property(x => x.Roles, x => x.Type(typeof(RoleSetType), null)); 
+4
source

Source: https://habr.com/ru/post/1385337/


All Articles