I have a simple QueryOver
var q = SessionInstance.QueryOver<Person>().Where(p => p.Number.Equals(number));
Number field type is int.
This query has a runtime error by this message:
Unrecognised method call: System.Int32:Boolean Equals(Int32)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
==operator generates a BinaryExpression which can be converted to SQL and the.Equals()method generates a MethodCallExpression which apparently is not converted to SQL.Usually the binary operators are handled in
QueryOverand also in Linq but only a few method calls are handled (string.Contains,array.Contains, etc.) so you better use operators when possible.Also remember that the operators/method calls are not actually executed, but converted SQL statements so if you have custom overrides/implementations for them they might not work as expected.
Given the above your code would be rewritten as: