[英]Mapping Enum Error FluentNhibernate
我想將一個enum
映射到mysql
數據庫。
class CommisionWorking
{
public enum Color{ O, PP, FP };
}
這是我的mapping
類。
class CommisionWorkingMap : ClassMap<CommisionWorking>
{
public CommisionWorkingMap()
{
Map(x => x.Color).CustomType<typeof(Color));
}
這顯示了一個錯誤。 試過了
Map(x=>x.Color).CustomType<GenericEnumMapper<Color>>
Map(x => x.Color).CustomType();
兩者都顯示錯誤。
請幫忙。
我會說,這里提到的解決方案沒有什么不同:
因此,如果表包含整數列,我們可以像這樣映射它:
// instead of any of these
// Map(x => x.Color).CustomType<typeof(Color));
// Map(x => x.Color).CustomType<GenericEnumMapper<Color>>
// Map(x => x.Color).CustomType();
// this will map color to integer column with values 0 == O, 1 == PP...
Map(o => o.Color);
如果您有字符串列(值O,PP,...),則您的嘗試應該起作用:
Map(x => x.Color).CustomType<GenericEnumMapper<Color>>
如此處所述: 如何在流利的nhibernate中將枚舉映射為字符串?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.