tags:

views:

10

answers:

1

[NUnit.Framework.Test] public void Test2() { NHibernate.ISession session = Z.Core.NHibernateCore.NHibernateHelper.GetCurrentSession(); var crit = session.CreateCriteria("_School"); crit.CreateCriteria("ListStudent", "_ListStudent", NHibernate.SqlCommand.JoinType.LeftOuterJoin); crit.Add(NHibernate.Criterion.Expression.Eq("__ListStudent.Name", "Abc")); var list = crit.List(); Console.Write(list.Count); }

NHibernate: SELECT * FROM Tst_School this_ left outer join Tst_Student liststud1_ on this_.Guid=liststud1_.Guid WHERE liststud1_.Name = 'Abc' How to create sql: SELECT * FROM Tst_School this_ left outer join Tst_Student liststud1_ on this_.Guid=liststud1_.Guid AND liststud1_.Name = 'Abc'

Thanks

A: 

You should check WITH clause in HQL. I don't know if it's possible in CriteriaQuery.

http://nhforge.org/blogs/nhibernate/archive/2009/05/17/nhibernate-2-1-0-hql-with-clause.aspx

dmonlord