Nhibernate fluent bool to smallint mapping

In my application, I have a bool property called DisplayIndicator. In a database (DB2), this corresponds to the DISPL_IND column of type smallint. The correspondence is as follows: [DisplayINdicator = True, DISPL_IND = 1] and [DisplayINdicator = False, DISPL_IND = 0] Is it possible to map the bool property for smallint using nhibernate?

+3
source share
2 answers

I get it after France advises. I created a class that represents the nhibernate user type used to map a boolean type to a short type:

public class BooleanAsShortType: IUserType

CustomType, :

(x = > x.DisplayIndicator, "DSPL_IND" ). CustomType <BooleanAsShortType> ();

+2

IUserType bool , .

+1

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


All Articles