コード例 #1
0
        public void Seila()
        {
            var exp = "select * from Person.Person where FirstName = 'David' AND JobTitle = 'Developer'";
            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .Where("{0} = {1} AND {2} = {3}", "FirstName", "'David'", "JobTitle", "'Developer'");

            Assert.AreEqual(exp, q.ToString(), true);
        }
コード例 #2
0
        public void Simple_Select_Using_Order_By()
        {
            var exp = "select * from Person.Person order by PersonID";

            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .OrderBy("PersonID");

            Assert.AreEqual(exp, q.ToString(), ignoreCase: true);
        }
コード例 #3
0
        public void Simple_Select_Should_Work_As_Expected()
        {
            var expected = "select * from HumanResources.Employee";
            var expected2 = "select JobTitle, BirthDate FROM HumanResources.Employee";
            var expected3 = "select * from Person.Person";

            Query query = new SqlServerQuery();
            query.Select("*").From("HumanResources.Employee");

            Query query2 = new SqlServerQuery()
                .Select("JOBTITLE", "BIRTHDATE")
                .From("HumanResources.Employee");

            Query query3 = new SqlServerQuery()
                .Select("* FROM Person.Person");

            Assert.AreEqual(expected, query.ToString(), true);
            Assert.AreEqual(expected2, query2.ToString(), true);
            Assert.AreEqual(expected3, query3.ToString(), true);
        }
コード例 #4
0
        public void Simple_Select_With_WhereClause_Should_Work_As_Expected()
        {
            var exp = "select * from HumanResources.Employee where VacationHours >= 60";
            var exp2 = "select * from HumanResources.Employee where JobTitle = 'Research and Development Engineer'";

            Query query = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("VacationHours >= 60");

            Query query2 = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("JobTitle = 'Research and Development Engineer'");

            Assert.AreEqual(exp, query.ToString(), true);
            Assert.AreEqual(exp2, query2.ToString(), true);
        }
コード例 #5
0
        public void Simple_Select_With_WhereClause_With_Two_Conditions_Should_Work_As_Expected()
        {
            var exp = "select * from HumanResources.Employee where VacationHours >= 60 AND SickLeaveHours < 100";

            Query q = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .Where("VacationHours >= 60")
                .Where("SickLeaveHours < 100");

            Assert.AreEqual(exp, q.ToString(), true);
        }
コード例 #6
0
        public void Simple_Select_With_WhereClause_Using_StartsWith()
        {
            var exp = "select * from Person.Person where FirstName LIKE 'Em%'";

            var q = new SqlServerQuery()
                .Select("*")
                .From("Person.Person")
                .WhereField("FirstName")
                .StartsWith("Em");

            Assert.AreEqual(exp, q.ToString(), true);
        }
コード例 #7
0
        public void Simple_Select_With_WhereClause_Using_Contains()
        {
            var exp = "select * from HumanResources.Employee where JobTitle LIKE '%Manager%'";
            var q = new SqlServerQuery()
                .Select("*")
                .From("HumanResources.Employee")
                .WhereField("JobTitle")
                .Contains("Manager");

            Assert.AreEqual(exp, q.ToString(), true);
        }