views:

903

answers:

1

What is the best way to get the reverse behavior of the YesNo Boolean type in NHibernate mapping?

I want 'Y' to mean false and 'N' to mean true.

Is there a NoYes type? Do you write a custom type? something really easy?

This issue of needing to reverse the Boolean exists on at least one field on over 40 tables. Trying to adapt to a legacy database.

+4  A: 

I have found that dealing with weird data formats in legacy databases can be achieved easily by implementing custom types. For example, I recently made a simple user type to map DateTime to 8 digit numbers on the form yyyyMMdd, which happened to be the way the dates were stored in a DB2 dump I had to use.

Los Techies have an example on implementing IUserType that you can use to solve your problem: Mapping Strings to Booleans Using NHibernate's IUserType.

mookid8000