예제 #1
0
        public void ExecuteScalar()
        {
            var count = NorthwindAdoRepository.ExecuteScalarBySqlString("SELECT COUNT(*) FROM dbo.Orders").AsInt();

            Assert.Greater(count, 0);

            var filterCount
                = NorthwindAdoRepository
                  .ExecuteScalarBySqlString("SELECT COUNT(*) FROM Orders where OrderDate < @OrderDate and Freight < @Freight",
                                            new AdoParameter("OrderDate", DateTime.Today),
                                            new AdoParameter("Freight", 2))
                  .AsInt();

            Assert.Greater(filterCount, 0);

            var orderId =
                NorthwindAdoRepository
                .ExecuteScalarBySqlString("SELECT TOP 1 ISNULL(OrderID, 0) FROM Orders ORDER BY ShippedDate")
                .AsInt(0);

            Assert.AreNotEqual(0, orderId);

            orderId =
                NorthwindAdoRepository
                .ExecuteScalarBySqlString("SELECT TOP 1 ISNULL(OrderID, 0) FROM Orders Where ShipVia=0 ORDER BY ShippedDate")
                .AsInt(0);

            Assert.AreEqual(0, orderId);
        }
        public static int TotalRows()
        {
            var result = NorthwindAdoRepository.ExecuteScalarBySqlString(SQL_REGION_COUNT);

            return(Convert.ToInt32(result));
        }