public void CanGetMultiQueryFromSecondLevelCache()
        {
            CreateItems();
            //set the query in the cache
            DoMutiQueryAndAssert();

            var cacheHashtable  = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions);
            var cachedListEntry = (IList) new ArrayList(cacheHashtable.Values)[0];
            var cachedQuery     = (IList)cachedListEntry[1];

            var firstQueryResults = (IList)cachedQuery[0];

            firstQueryResults.Clear();
            firstQueryResults.Add(3);
            firstQueryResults.Add(4);

            var secondQueryResults = (IList)cachedQuery[1];

            secondQueryResults[0] = 2;

            using (var s = sessions.OpenSession())
            {
                var criteria = s.CreateCriteria(typeof(Item))
                               .Add(Restrictions.Gt("id", 50));
                var multiCriteria = s.CreateMultiCriteria()
                                    .Add(CriteriaTransformer.Clone(criteria).SetFirstResult(10))
                                    .Add(CriteriaTransformer.Clone(criteria).SetProjection(Projections.RowCount()));
                multiCriteria.SetCacheable(true);
                var results = multiCriteria.List();
                var items   = (IList)results[0];
                Assert.AreEqual(2, items.Count);
                var count = (int)((IList)results[1])[0];
                Assert.AreEqual(2L, count);
            }
        }
        public void CanUseSecondLevelCacheWithPositionalParameters()
        {
            var cacheHashtable = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(Sfi);

            cacheHashtable.Clear();

            CreateItems();

            DoMutiQueryAndAssert();

            Assert.AreEqual(1, cacheHashtable.Count);
        }
        public void CanGetMultiQueryFromSecondLevelCache()
        {
            CreateItems();
            //set the query in the cache
            DoMutiQueryAndAssert();

            Hashtable cacheHashtable  = MultipleQueriesFixture.GetHashTableUsedAsQueryCache(sessions);
            IList     cachedListEntry = (IList) new ArrayList(cacheHashtable.Values)[0];
            IList     cachedQuery     = (IList)cachedListEntry[1];

            IList firstQueryResults = (IList)cachedQuery[0];

            firstQueryResults.Clear();
            firstQueryResults.Add(3);
            firstQueryResults.Add(4);

            IList secondQueryResults = (IList)cachedQuery[1];

            secondQueryResults[0] = 2L;

            using (ISession s = sessions.OpenSession())
            {
                IMultiQuery multiQuery = s.CreateMultiQuery()
                                         .Add(s.CreateSQLQuery("select * from ITEM where Id > ?").AddEntity(typeof(Item))
                                              .SetInt32(0, 50)
                                              .SetFirstResult(10))
                                         .Add(s.CreateQuery("select count(*) from Item i where i.Id > ?")
                                              .SetInt32(0, 50));
                multiQuery.SetCacheable(true);
                IList results = multiQuery.List();
                IList items   = (IList)results[0];
                Assert.AreEqual(2, items.Count);
                long count = (long)((IList)results[1])[0];
                Assert.AreEqual(2L, count);
            }

            RemoveAllItems();
        }