Ignore parameters when using ISQLQuery in NHibernate

674 Views Asked by At

I have to execute a native sql statement with NHibernate to the database. For this, i use:

var query = session.CreateSQLQuery(sql);
query.ExecuteUpdate();

Now, the sql contains the character : in a Column-Alias (which I need on this way) and NHibernate is handling this with a parameter. I haven't any parameter in this sql statement. Can I define somewhere, that NHibernate should not manage parameters for this ISQLQuery?

1

There are 1 best solutions below

0
On BEST ANSWER

Just use native connection for native SQL execution:

var cmd = session.Connection.CreateCommand(); // session is a NHibernate session
cmd.CommandText = sql;
cmd.ExecuteNonQuery();