Cannot pass an object of type "NHibernate.Hql.Ast.HqlBitwiseAnd" to enter "NHibernate.Hql.Ast.HqlBooleanExpression"

I have the following code segment in which I get an error

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; } } 

in if statement, I get an error

 Unable to cast object of type 'NHibernate.Hql.Ast.HqlBitwiseAnd' to type 'NHibernate.Hql.Ast.HqlBooleanExpression'. 
+4
source share
1 answer

What about:

 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; } } 

Check the double ampersand in the query right in the where part.

+7
source

Source: https://habr.com/ru/post/1393644/


All Articles