2

I want to do this with a nhibernate criteria:

SELECT Text FROM Table WHERE Text Like 'Re% Wi%'

The result should be:

Red Wine

I have the search parameter as a string 'Re Wi' from the user interface.

What is the best approach? split the string and put % at the end, join the string array and end up with:

criteria.Add(Restrictions.Like("Text", 'Re% Wi%', MatchMode.Start))

Or can I add the individual parts (beginning of words) to some criteria expression?

Erik Sundström
  • 997
  • 1
  • 12
  • 29
  • 1
    I don't see what's wrong with your current approach. – Vadim Mar 29 '11 at 14:16
  • i have to agree with vadim, the criteria api does not allow for this particular manipulation so just insert the '%' on after each token – Jaguar Mar 29 '11 at 19:23
  • Ok, I'll do the % on each token approach, just thought that I've missed some API stuff since I'm new to writing criteria – Erik Sundström Mar 30 '11 at 06:49

0 Answers0