本文介绍了你如何将一个枚举映射为一个int值与流利的NHibernate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题确实如此,默认是映射为字符串,但我需要它映射为 int PersistenceModel 来设置我的约定,如果这有什么区别的话。提前致谢。

更新
发现从中继获取最新版本的代码解决了我的问题。

解决方案



<$公共类接受(IAcceptanceCriteria< IPropertyInspector>标准)
{
criteria.Expect(x =>> ; x.Property.PropertyType.IsEnum);
}

public void Apply(IPropertyInstance target)
{
target.CustomType(target.Property.PropertyType);
}
}


Question says it all really, the default is for it to map as a string but I need it to map as an int.

I'm currently using PersistenceModel for setting my conventions if that makes any difference. Thanks in advance.

UpdateFound that getting onto the latest version of the code from the trunk resolved my woes.

解决方案

The way to define this convention changed sometimes ago, it's now :

public class EnumConvention : IUserTypeConvention
{
    public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
    {
        criteria.Expect(x => x.Property.PropertyType.IsEnum);
    }

    public void Apply(IPropertyInstance target)
    {
        target.CustomType(target.Property.PropertyType);
    }
}

这篇关于你如何将一个枚举映射为一个int值与流利的NHibernate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 21:50