I have 2 tables (Task table and user table)
task table have list of users
how to select tasks where userName is "xx"
using criteria in nhibernate 2
Asked
Active
Viewed 90 times
0

Amir Salah
- 31
- 9
1 Answers
1
var tasks = _session.QueryOver<Task>()
.Fetch(x => x.User).Eager
.Where(x => x.User.Username == "xx")
.List();
or
User userAlias = null;
var tasks = _session.QueryOver<Task>()
.JoinAlias(x => x.User, () => userAlias, JoinType.InnerJoin)
.Where(x=>userAlias.UserName=="xx")
.List();

Samuel Goldenbaum
- 18,391
- 17
- 66
- 104
-
Thanks for your answer but i work with nhibernate 2 (QueryOver not exist in it) – Amir Salah May 10 '12 at 12:04