Reputation: 22116
Having:
Person
which has a propriety Name
List<string> names
loaded with some namesHow can I query using criteria to obtain all Person instances who have a Name which is not found in the names list?
Thanks for answers!
Solution:
var myQuery = session.CreateCriteria(typeof(Person))
.Add(Expression.Not(Expression.In("Name", names));
Upvotes: 1
Views: 60
Reputation: 1049
var ps = from p in persons
where !list.Contains(p.Name)
select p;
Try this.
Upvotes: 0
Reputation: 15130
Your looking for an In expression, see: Nhibernate HQL where IN query
That would make your particular case something like:
ActiveRecordMediator<Person>.FindAll(Expression.Not(Expression.In("Name", names)))
Upvotes: 2