Пример #1
0
 /// <summary>
 /// Get the row count.
 /// </summary>
 /// <param name="session">The <see cref="ISession"/>.</param>
 /// <returns>The row count.</returns>
 public long GetRowsCount(ISession session)
 {
     if (dqrc == null)
     {
         dqrc = new QueryRowsCounter(GetRowCountQuery());
     }
     return(dqrc.GetRowsCount(session));
 }
        public void RowsCountUsingParameters()
        {
            IDetachedQuery dq =
                new DetachedQuery("select count(*) from Foo f where f.Name like :p1")
                .SetString("p1", "%1_");
            IRowsCounter rc = new QueryRowsCounter(dq);

            SessionFactory.EncloseInTransaction(s => Assert.AreEqual(5, rc.GetRowsCount(s)));
        }
Пример #3
0
        public void RowsCount()
        {
            IRowsCounter rc = new QueryRowsCounter("select count(*) from Foo");

            using (ISession s = OpenSession())
            {
                Assert.AreEqual(totalFoo, rc.GetRowsCount(s));
            }
        }
Пример #4
0
        public void RowsCountUsingParameters()
        {
            IDetachedQuery dq =
                new DetachedQuery("select count(*) from Foo f where f.Name like :p1").SetString("p1", "%1_");
            IRowsCounter rc = new QueryRowsCounter(dq);

            using (ISession s = OpenSession())
            {
                Assert.AreEqual(5, rc.GetRowsCount(s));
            }
        }
        public void InvalidRowsCount()
        {
            IRowsCounter rc = new QueryRowsCounter("select f.Name from Foo f");

            SessionFactory.EncloseInTransaction(s => Assert.Throws <HibernateException>(() => rc.GetRowsCount(s)));

            rc = new QueryRowsCounter("select f.Name from Foo f where f.Name='N1'");
            SessionFactory.EncloseInTransaction(s => Assert.Throws <HibernateException>(() => rc.GetRowsCount(s)));
        }
        public void RowsCount()
        {
            IRowsCounter rc = new QueryRowsCounter("select count(*) from Foo");

            SessionFactory.EncloseInTransaction(s => Assert.AreEqual(TotalFoo, rc.GetRowsCount(s)));
        }