public void NullLeftEntityJoinWithEntityProjection() { using (var sqlLog = new SqlLogSpy()) using (var session = OpenSession()) { EntityComplex ejLeftNull = null; EntityWithNoAssociation root = null; var objs = session.QueryOver(() => root) //add some non existent join condition .JoinEntityAlias(() => ejLeftNull, () => ejLeftNull.Id == null, JoinType.LeftOuterJoin) .Select((e) => root.AsEntity(), e => ejLeftNull.AsEntity()) .Take(1) .SingleOrDefault <object[]>(); root = (EntityWithNoAssociation)objs[0]; ejLeftNull = (EntityComplex)objs[1]; Assert.That(root, Is.Not.Null, "root should not be null (looks like left join didn't work)"); Assert.That(NHibernateUtil.IsInitialized(root), Is.True); Assert.That(ejLeftNull, Is.Null, "Entity join should be null"); Assert.That(sqlLog.Appender.GetEvents().Length, Is.EqualTo(1), "Only one SQL select is expected"); } }