I have som trouble using fulltext search in NHibernate ICriteria
I have registered freetext and contains as below:
public class CMSSQLDialect : MsSql2008Dialect {
public CMSSQLDialect()
{
RegisterFunction("freetext", new StandardSQLFunction("freetext", null));
RegisterFunction("contains", new StandardSQLFunction("contains", null));
}
}
Now i want to use the functions in an ICriteria like:
var store = sessionFactory.CreateCriteria(typeof(Comito.CMS.Domain.Entity.Document.Document));
var stringSearchProjection = Projections.SqlFunction("freetext", NHibernateUtil.StringClob, Projections.Property("BodyText"));
Trying to add the projection to the search:
store.Add(Restrictions.Eq(stringSearchProjection , '*mysearch*'));
(of course) returns
SELECT this_.BodyText as y0_ FROM TableName WHERE freetext(this_.BodyText) = 'dav'
But how do I then implement the freetext in ICriteria
In this case, we do not need to register SQL function for projections. We can just use it in the WHERE clause like that:
The
ExpressionisNHibernate.Criterion.Expression