2012-01-29 38 views
4

我有下面的代碼段中,我發現了錯誤無法投型「NHibernate.Hql.Ast.HqlBitwiseAnd」的對象鍵入「NHibernate.Hql.Ast.HqlBooleanExpression」上

using (var session = Database.OpenSession()) 
{ 
    var q = from x in session.Query<User>() 
      where x.UserName == username & x.Password==EncodePassword(password) 
      select x; 
    if (q.Count() > 0) 
    { 
     result = true; 
    } 
} 

if語句我收到提示

Unable to cast object of type 'NHibernate.Hql.Ast.HqlBitwiseAnd' to type 'NHibernate.Hql.Ast.HqlBooleanExpression'. 
+3

'BitWiseAnd'在這裏是一個非常大的提示:-) – diggingforfire 2012-01-29 19:46:34

+0

@diggingforfire我以爲同樣的事情...有時候,好的閱讀能夠改變它! – 2012-01-29 19:47:17

回答

7

什麼:

using (var session = Database.OpenSession()) 
{ 
    var q = from x in session.Query<User>() 
      where x.UserName == username && x.Password==EncodePassword(password) 
      select x; 
    if (q.Count() > 0) 
    { 
     result = true; 
    } 
} 

檢查雙符號在您的查詢,就在where部分。

相關問題