queryover and (x like ‘a’ or y like ‘a’)

You could use the NHibernate Disjunction class to do this in a more elegant (IMHO) fashion:

var disjunction= new Disjunction();

disjunction.Add(Restrictions.On<Type>(e => e.Code).IsLike(codePart));
disjunction.Add(Restrictions.On<Type>(e => e.Description).IsLike(codePart));
//(and so on)

and then:

query.Where(disjunction)

Each “OR” is a separate instruction, which helps if you want to add the predicates conditionally.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)