On Wednesday, September 14, 2011 3:44:07 PM UTC-4, Tim Scott wrote: > > I didn't notice that CharBooleanType is abstract. There's TrueFalseType and > YesNo type, neither of which are what you need. Two ideas: > > One of the answers to this post says you can do it with query substitutions > alone. You might try that. You probably want to set query substitutions in > any case. > > http://stackoverflow.com/questions/7404991/fluentnhibernate-how-to-map-database-char-to-c-bool > > But there is no XML configuration for FluentNHibernate, so I don't understand how query subsititution works.
> Otherwise, you can do it for sure with a custom IUserType: > > http://lostechies.com/rayhouston/2008/03/23/mapping-strings-to-booleans-using-nhibernate-s-iusertype/ > > Copy the sample code and just change the NullSafeGet and NullSafeSet to the > behavior you want. Then map your custom type in FNH (instead of > CharBooleanType). > After some research, I kinda realized that I may have to implement my own user type, but then thought if this is an overkill for such a small task (converting a char/string to bool). This kind of casting comes up pretty often, maybe this should be built into FluentNHibernate? But for now, if this is something I have to do, I'll do it. Not the next time. :-) > > On Wednesday, September 14, 2011 at 1:43 PM, Influently NHiberater wrote: > > > > > On Wednesday, September 14, 2011 2:26:13 PM UTC-4, Influently NHiberater > wrote: > > > > > > On Wednesday, September 14, 2011 1:55:39 PM UTC-4, Tim Scott wrote: > > > > Try this: > > > > Map(x=>x.IsActive).Column("is_active").CustomType<CharBooleanType>() > > > > -- > > > > Tim Scott > > > > Lunaverse Software > > > > > > OK, just found that CharBooleanType is under NHibernate.Type. So, I tried > like what you said: > > > > Map(x => > x.IsActive).Column("is_active").CustomType<NHibernate.Type.CharBooleanType>(); > > > > No build error, but at compile time, I got this: > > > > An invalid or incomplete configuration was used while creating a > SessionFactory. Check PotentialReasons collection, and InnerException for > more detail. > > > > ----> FluentNHibernate.Cfg.FluentConfigurationException : An invalid or > incomplete configuration was used while creating a SessionFactory. Check > PotentialReasons collection, and InnerException for more detail. > > > > ----> NHibernate.MappingException : Could not compile the mapping > document: (XmlDocument) > > ----> NHibernate.MappingException : Could not instantiate IType > CharBooleanType: System.MissingMethodException: Cannot create an abstract > class. > > > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups "Fluent NHibernate" group. > > To view this discussion on the web visit > https://groups.google.com/d/msg/fluent-nhibernate/-/f9yCrRQed_YJ. > > To post to this group, send email to [email protected](mailto: > [email protected]). > > To unsubscribe from this group, send email to > [email protected] (mailto: > [email protected]). > > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To view this discussion on the web visit https://groups.google.com/d/msg/fluent-nhibernate/-/gdfLrB2oWoQJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.
