Hi
Given a list of strings I want to retrieve all items whose names contain one of the given strings.
for example- given {\"foo\", \"kuku\"} I want to retrieve the emplo
If you are not limited to the Linq provider but also open to the ICriteria API, I suggest using the following:
List fullnames = new List() { "foo", "kuku" };
// prepare Query
var query = session.CreateCriteria(typeof(Employee));
// dynamically add Like-conditions combined with OR
Disjunction namesCriteria = Restrictions.Disjunction();
foreach (var name in fullnames)
{
namesCriteria.Add(Restrictions.Like("FullName", name, MatchMode.Anywhere));
}
// add complete Disjunction to prepared query
query.Add(namesCriteria);
IList list = query.List();
I think trying that in NHibernate.Linq might be harder if not impossible. With NH 3.0 you could use QueryOver, which would get rid of the magic strings.