Using NHibernate with Linq or Criterion, is it possible to do a LIKE query on a GUID column?
In T-SQL this is easy: *select * from mytable where id like '0ae%'*
NHibernate won't convert the Guid to a string though.
Using NHibernate with Linq or Criterion, is it possible to do a LIKE query on a GUID column?
In T-SQL this is easy: *select * from mytable where id like '0ae%'*
NHibernate won't convert the Guid to a string though.
I found the answer - I need to use projections. Here's what I came up with:
var query = Session.CreateCriteria(typeof (MyClass))
.Add(Restrictions.Like(
Projections.Cast(NHibernateUtil.String, Projections.Property("Id")),
'%'+keywords+"%"));