I need to execute a query that looks roughly like this in SQL:
select * from Codes where Value1 like '%' + Value2 + '%'
Is there a way to do it using FluentNHibernate and QueryOver
? I was looking for something like this
Session.Query<Code>().WhereRestrictionOn(c => c.Value1).IsLike(c => c.Value2);
but unfortunately IsLike
requires an object
or a string
value as an argument.
One way here would be to use just a raw SQL Criterion:
It represents the raw SQL, so we have to use column names, not mapped properties here... But for exceptional scenarios like this, this is the NHibernate extension point