-
Notifications
You must be signed in to change notification settings - Fork 934
Evaluation failure when using Nullable
without a value in LINQ
#3156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You should always provide NHibernate version (looks like 5.4 dev is used) As a workaround use null check instead : Just for reference (looks like similar issue): dotnet/coreclr@75d1d39 |
Does NHibernate recognize the call to the Value property and internally understand that it can't actually call that if the nullable is null? (I don't know if that has been implemented). Does this work:
|
Another workaround would be to avoid using a condition related only to parameters values in the query. That generally generates queries with better performances. But it also generates more queries, which could be an issue in some circumstances. var query = session.Query<Role>();
if (isActive.HasValue)
query = query.Where(r => r.IsActive == isActive);
var results = query.ToList(); Oskar, the error message lets infer the trouble occurs when evaluating I think NHibernate supports |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
So, actually this bug has not been released. Should we switch it to t:fix in order not to mention a bug which was never released? |
Using
Nullable<T>.HasValue
in LINQ throwsNHibernate.HibernateException: Evaluation failure on null.HasValue
if no value is set.Test case
Error details
The text was updated successfully, but these errors were encountered: