1

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?

BennoDual
  • 5,865
  • 15
  • 67
  • 153
  • possible duplicate of [How to escape colon (:) character while executing native SQL queries against an Informix database using NHibernate?](http://stackoverflow.com/questions/9845130/how-to-escape-colon-character-while-executing-native-sql-queries-against-an) – Najera Aug 13 '14 at 20:58
  • I cannot use the solution of this other question because I have the colon in the alias of a column and cannot replace it. – BennoDual Aug 13 '14 at 21:23

1 Answers1

0

Just use native connection for native SQL execution:

var cmd = session.Connection.CreateCommand(); // session is a NHibernate session
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
user2291296
  • 334
  • 3
  • 11