Hi all NHibernate gurus !
Given these two classes :
public class User {
long Id;
string Name;
}
public class Project {
long Id;
User Owner;
IList<User> Managers;
...
}
I would like to do a query using QueryOver (not using criteria "magic string" aliases), to get all projects having user1 as Owner OR as one of the Managers.
I know how to separately :
but I don't know how to write the disjunction.
If someone had an idea, it would help me a 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 to change filter from Name
to Id
(as OP pointed out):-
.Where(w=>manager.Id == user1.Id || w.Owner.Id == user1.Id)
edit2 to change inner to left use
.JoinAlias(j => j.Managers, () => manager).left
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With