using System; using System.Collections.Generic; using System.Linq; using System.Text; using NHibernate.Criterion; using NHibernate.SqlCommand; using NHibernate.Test.NHSpecificTest.NH1914; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH_3472 { [TestFixture] public class CriteriaQueryWithMultipleJoinsToSameAssociation : BugTestCase { [Test] public void NH_3472() { int catId; using (ISession sess = OpenSession()) { Cat c = new Cat(); c.Children = new List {new Cat {Color = "Ginger", Age = 1}, new Cat {Color = "Black", Age = 3}}; sess.Save(c); sess.Flush(); } using (ISession sess = OpenSession()) { var list = sess.CreateCriteria("cat") .CreateAlias("cat.Children", "gingerCat", JoinType.LeftOuterJoin, Property.ForName("Color").Eq("Ginger")) .CreateAlias("cat.Children", "blackCat", JoinType.LeftOuterJoin, Property.ForName("Color").Eq("Black")) .SetProjection( Projections.Alias(Projections.Property("gingerCat.Age"), "gingerCatAge"), Projections.Alias(Projections.Property("blackCat.Age"), "blackCatAge") ).List(); } } } }