0

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

Amir Salah
  • 31
  • 9

1 Answers1

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