NHibernate Worst Practice - SQL

time to read 1 min | 114 words

The question just came up in the NHibernate dev list, and I wanted to be as clear about this as possible.

If you can at all avoid it, do so. The use of SQL in NHibernate should be strongly discouraged. It is there to give you the ability to use the proprietary features of your database, and as a way to avoid the abstraction if you really need that.

The problem is when people are using that for things that they really shouldn't, like complex queries that they know how to express in SQL but not using NHibernate, so they drop to that. This is not what it is for, and it will bite you later.