在我的应用程序中,我有一个名为 DisplayIndicator 的 bool 属性。在数据库 (DB2) 中,它对应于 smallint 类型的 DISPL_IND 列。 信件如下: [DisplayINdicator=True, DISPL_IND=1] 和 [DisplayINdicator=False, DISPL_IND=0] 是否可以使用 nhibernate fluence 将 bool 属性映射到 smallint?
最佳答案
在 Frans 的建议下,我弄明白了。 我创建了一个代表 nhibernate 用户类型的类,用于将 bool 类型映射到短类型:
公共(public)类 BooleanAsShortType : IUserType
在映射中,我添加了一个 CustomType 属性,现在它看起来像这样:
Map(x => x.DisplayIndicator, "DSPL_IND").CustomType< BooleanAsShortType >();
关于c# - nhibernate fluent bool 到 smallint 映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3044310/