-
Notifications
You must be signed in to change notification settings - Fork 936
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
Failure of contains subquery with parameter #3218
Comments
The question mark signifies the SQL parameter, so that's correct. I'm not able to reproduce the problem. However, using discard lambda parameters (underscore) is a potentially bad idea, and if there's any (badly written) expression rewriting going on, where the parameter names are relevant, it may be a good idea to write |
Thank for your quick answer. I just tried renaming the lambda parameters but it doesn't work. I can run manually the generated query correctly after replacing the ? with the Guid, so query generation looks good too, and in v5.3.10 that code works, that's why I think it might be some bug introduced in v5.3.11. I hope somebody is able to reproduce it so we can find a solution for this. |
To my surprise we never properly supported Contains(parameter) subqueries with Select. ... AND subquery.ID = @name` while it should be comparison on Name: ... AND subquery.Name = @name` It started working by chance for your case in 5.3 due to other bug :) As a workaround you can use _.Clients.Any(_ => _.Id == clientId) |
Oh, ok. Good to know, thank you for your reply. Yes, with the Any it works fine. I see you created a new feature to support the Contains(parameter), and I would prefer delaying my version update than rewriting multiple places where we use the Contains into Any. |
Fixed by #3220 |
I tried to update NHibernate from version v5.3.3 to v5.4 and I noticed that until v.5.3.10, the following code worked fine:
But since v5.3.11, in that line I get an exception, with the following message:
{"Unable to cast object of type 'System.Guid' to type 'Contoso.ProjectName.Domain.Client'."}
The generated query is:
Looks like the p1 value is not placed in the generated query, but a ? appears in its place.
The text was updated successfully, but these errors were encountered: