tags:

views:

28

answers:

1

Say I have a query like:

session.CreateCriteria(typeof(Category)) .Add( Expression.Like("Name", someVariable) );

WHere someVariable was taken from the querystring, do I have to do checks against sql injection or will nhibernate handle this?

+2  A: 

it's handled for you, but to be sure try to do an sql injection, just to prove it's ok.

David Roussel
+1 This is the correct answer, but to go into a bit more detail on your answer David, the way that this is handled is that NHibernate parameterises your entire query before sending it off to the database server. To see this in action have a look at a profiler like NHProf (www.nhprof.com) so you can see the exact steps taken by NHibernate in this case :)
Jay
good point Jay, +1.
David Roussel