I want to use collation in a query in NHibernate and apparently the only way to do that (at least from what I found) is through adding an sql expression (Can I customize collation of query results in nHibernate?)
So I have something like
c.Add(Expression.Sql("Title COLLATE Divehi_90_BIN2 LIKE ?",
title,
NHibernateUtil.String))
However this matches the exact string and I want to use % on both sides.
Title COLLATE Divehi_90_BIN2 LIKE %?%
gives me an error,
but padding it on the title: "%" + title + "%"
works.
My question is - Is there a way to properly give parameters in Expression.Sql because using the % on both sides looks like a security flaw - that I am inviting query injection.
PS. I can't change the collation of the column at the database level because the column contains data that are of two languages.