2009-07-17 162 views
0

這是一個錯誤? 使用NHibernate.Expression.Example.Create(userExample)如果我的類在屬性'Type'上使用Int32一切正常。Nhibernate枚舉錯誤

public class User:Person 
{ 

    public virtual String NickName { get; set; } 
    public virtual String Password { get; set; } 
    public virtual Int32 Type { get; set; } 

    public enum UserType 
    { 
     Normal = 0, 
     Broker = 1 
    } 

} 

但使用枚舉的標準返回NULL:

public class User:Person 
{ 
public virtual String NickName { get; set; } 
public virtual String Password { get; set; } 
public virtual UserType Type { get; set; } 

public enum UserType 
{ 
    Normal = 0, 
    Broker = 1 
} 

}

在控制檯,查詢出現「經紀人」,這是問題,我認爲這是一個錯誤NHibernate的,任何sugestions?

+0

你可以發佈你的映射嗎? – mxmissile 2009-07-17 15:57:59

回答

1

沒有看到你的查詢,你可以試試這個表達式。我假設你將枚舉存儲爲int你的分貝。

Expression.Eq("Type",(int) userType); 
+0

是的是一個int字段。當我保存用戶導致NHibernate然後暗示轉換UserType爲int,但使用ByExample method..XD! (「Type」,((int)userType);這是一種獨特的方式: 這是獨特的方式: Expression.Eq ?????? – JoeLoco 2009-07-17 15:22:43