Why doesn't ICriteria pass variable value to the withClause?
-
30-10-2019 - |
문제
I'm trying to restrict a left outer join with a simple restriction but it fails with an sql exception.
System.Data.SqlClient.SqlException: Must declare the scalar variable "@p1".
My ICriteria:
var r = session.CreateCriteria<Parent>("p")
.CreateCriteria("p.Children", "c", NHibernate.SqlCommand.JoinType.LeftOuterJoin, Restrictions.Eq("c.Name", "John Doe"))
.List();
The desired SQL:
SELECT * FROM Parents p
LEFT OUTER JOIN Children c ON c.ParentID = p.ID AND c.Name = 'John Doe'
Do I have to add the variable values in any way? The SQL generated by NHibernate is correct but the variable just isn't sent to the server.
올바른 솔루션이 없습니다
제휴하지 않습니다 StackOverflow