public void TestCriteriaCompiled3()
        {
            long carCount = 0;
            IList l0 = null;
            using (ISession session = SessionFactory.OpenSession())
            {
                carCount = session.CreateQuery("select count(*) from CarContract").UniqueResult<long>();
                l0 = session.CreateQuery("from CarContract").List();
            }

            ICriteriaCompiled criteriaCompiled = null;
            ICriteriaBuilder criteriaBuilder = new CriteriaBuilder(SessionFactory.GetClassMetadata);
            CarContract instance = new CarContract
            {
                Owner = new Salesman {Name = "Manuel"}
            };

            criteriaCompiled = criteriaBuilder.MakeCriteria(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "carContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(CarContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 3);
            }


            instance.Owner = new Salesman(0);
            criteriaCompiled = criteriaBuilder.MakeCriteria(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "carContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(CarContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 0);
            }


            instance.Owner = new Salesman{Name = "pippo"};
            criteriaCompiled = criteriaBuilder.MakeCriteria(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "carContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(CarContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 0);
            }
        }
        public void TestCriteriaCompiled4()
        {
            ICriteriaCompiled criteriaCompiled = null;
            ICriteriaBuilder criteriaBuilder = new CriteriaBuilder(SessionFactory.GetClassMetadata);
            CarContract instance = new CarContract
            {
                Owner = new Salesman(1)
            };

            criteriaCompiled = criteriaBuilder.MakeCriteria<TradeContract>(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "tradeContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(TradeContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);

            var relationship = criteriaCompiled.FindRelationshipProperty("Owner");
            Assert.IsNotNull(relationship);

            Assert.AreEqual(relationship.Type, typeof(Salesman));
            Assert.AreEqual(relationship.Alias, "salesman");
            Assert.AreEqual(relationship.GetPath(), "tradeContract.Owner");

            //PersistentLayer.Domain.Salesman aaa = new PersistentLayer.Domain.Salesman();
            
        }
        public void TestCriteriaCompiled2()
        {
            ICriteriaCompiled criteriaCompiled = null;
            ICriteriaBuilder criteriaBuilder = new CriteriaBuilder(SessionFactory.GetClassMetadata);
            CarContract instance = new CarContract
                {
                    Owner = new Salesman(1)
                };

            criteriaCompiled = criteriaBuilder.MakeCriteria(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "carContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(CarContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 3);
            }

            criteriaCompiled = criteriaBuilder.MakeCriteria(typeof(CarContract), instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "carContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(CarContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 3);
            }

            criteriaCompiled = criteriaBuilder.MakeCriteria<TradeContract>(instance);
            Assert.AreEqual(criteriaCompiled.RootAlias, "tradeContract");
            Assert.AreEqual(criteriaCompiled.RootType, typeof(TradeContract));
            Assert.AreEqual(criteriaCompiled.Restrictions.Count(), 2);
            using (ISession session = SessionFactory.OpenSession())
            {
                var lista = criteriaCompiled.Criteria.GetExecutableCriteria(session).List();
                Assert.AreEqual(lista.Count, 4);
            }
        }