Exemplo n.º 1
0
        public async Task MultiCriteriaQueriesWithStringsShouldExecuteCorrectlyAsync()
        {
            var driver = Sfi.ConnectionProvider.Driver;

            if (!driver.SupportsMultipleQueries)
            {
                Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName);
            }

            // Test querying StringData
            using (ISession session = this.OpenSession())
            {
                ICriteria criteriaWithPagination = session.CreateCriteria <DomainClass>();
                criteriaWithPagination.Add(Expression.Like("StringData", "%Doe%"));
                ICriteria criteriaWithRowCount = CriteriaTransformer.Clone(criteriaWithPagination);
                criteriaWithPagination.SetFirstResult(0).SetMaxResults(1);
                criteriaWithRowCount.SetProjection(Projections.RowCountInt64());

                IMultiCriteria multiCriteria = session.CreateMultiCriteria();
                multiCriteria.Add(criteriaWithPagination);
                multiCriteria.Add(criteriaWithRowCount);

                IList results = await(multiCriteria.ListAsync());

                long  numResults = (long)((IList)results[1])[0];
                IList list       = (IList)results[0];

                Assert.AreEqual(2, await(criteriaWithRowCount.UniqueResultAsync <long>()));
                Assert.AreEqual(1, list.Count);
            }
        }