示例#1
0
        public void SQLWithISNull_1()
        {
            var p = new Models.Products();

            Verify(
                Select(p.ProductName, Multiply(p.UnitPrice, Add(p.UnitsInStock, IfNull(p.UnitsOnOrder, 0))))
                ,
                @"SELECT ProductName, UnitPrice * (UnitsInStock + ISNULL(UnitsOnOrder, 0))
                FROM Products"
                );
        }
示例#2
0
        public void SQLWithNotBetween()
        {
            var p = new Models.Products();

            Verify(
                Select(p.ProductID).Where(Not(p.UnitPrice.IsBetween(10, 20)))
                ,
                @"SELECT ProductID FROM Products
                  WHERE UnitPrice Not BETWEEN 10 AND 20"
                );
        }
示例#3
0
        public void SQLWithISNull()
        {
            var p = new Models.Products();

            Verify(
                Select(p.ProductName, IfNull(p.UnitsOnOrder, 0))
                ,
                @"SELECT ProductName, ISNULL(UnitsOnOrder, 0)
                FROM Products"
                );
        }
示例#4
0
        public void SQLWithAvg()
        {
            var p = new Models.Products();

            Verify(
                Select(Average(p.UnitPrice)).From(p)
                ,
                @"SELECT AVG(UnitPrice)
                  FROM Products"
                );
        }
示例#5
0
        public void SQLWithCount()
        {
            var p = new Models.Products();

            Verify(
                Select(Count(p.ProductID)).From(p)
                ,
                @"SELECT COUNT(ProductID)
                  FROM Products"
                );
        }
示例#6
0
        public void SQLWithMax()
        {
            var p = new Models.Products();

            Verify(
                Select(Max(p.UnitPrice)).From(p)
                ,
                @"SELECT MAX(UnitPrice) AS LargestPrice
                  FROM Products"
                );
        }
示例#7
0
        public void SQLWithMin()
        {
            var p = new Models.Products();

            Verify(
                Select(Min(p.UnitPrice)).From(p)
                ,
                @"SELECT MIN(UnitPrice) AS SmallestPrice
                  FROM Products"
                );
        }
示例#8
0
        public void SQLWithNotExists()
        {
            var od = new Models.Order_Details();
            var p  = new Models.Products();

            Verify(
                Select(od.OrderID).From(od).
                Where(NotExists(p, p.ProductID.IsEqualTo(od.ProductID).And(p.UnitPrice.IsEqualTo(22))))
                ,
                @"SELECT OrderID
                FROM [Order Details]
                WHERE NOT EXISTS (SELECT ProductName FROM Products WHERE Products.ProductID = [Order Details].ProductID AND UnitPrice = 22) "
                );
        }