This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.When you execute an SQL query with NHibernate with named parameters, you would perhaps expect them to be prefixed with a symbol specific to the current DB you are accessing, for example, @ for SQL Server and : for Oracle; that is not the case. NHibernate requires that you always use it’s DB-neutral parameter prefix, :, the same that you use for HQL queries: //for SQL queries
session.CreateSQLQuery("SELECT * FROM [Order] WHERE Id = :id").SetParameter("id", 1).List();
//for HQL queries
session.CreateQuery("from Order where id = :id").SetParameter("id", 1).List(); Read more: Development With A Dot
QR:
session.CreateSQLQuery("SELECT * FROM [Order] WHERE Id = :id").SetParameter("id", 1).List();
//for HQL queries
session.CreateQuery("from Order where id = :id").SetParameter("id", 1).List(); Read more: Development With A Dot
QR:
0 comments:
Post a Comment