Restriction on collection with disjunction using NHibernate QueryOver -


hi nhibernate gurus !

given these 2 classes :

public class user {     long id;     string name; }  public class project {     long id;     user owner;     ilist<user> managers;     ... } 

i query using queryover (not using criteria "magic string" aliases), projects having user1 owner or 1 of managers.

i know how separately :

  • get projects having user1 owner : session.queryover<>project>>().where(p=>p.owner == user1)
  • get manager : session.queryover<>().joinalias(p=>p.managers, ()=>manager).where(()=>manager == user1)

but i don't know how write disjunction.

if had idea, me lot.

thanks in advance,

chris

something like:-

user manager = null;  var query = session     .queryover<project>()     .joinalias(j => j.managers, () => manager)     .where(w => manager.name == user1 || w.owner == user1)     .list<project>(); 

edit change filter name id (as op pointed out):-

.where(w=>manager.id == user1.id || w.owner.id == user1.id) 

edit2 change inner left use

.joinalias(j => j.managers, () => manager).left 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -