예제 #1
0
        public void Test_CityCountryAndCompanyNameTranslation()
        {
            var    translation        = string.Empty;
            string dbConnectionString = @"Server=(localdb)\\mssqllocaldb;Database=Northwind;Trusted_Connection=True;MultipleActiveResultSets=true";

            using (SqlConnection con = new SqlConnection(dbConnectionString))
            {
                Northwind db    = new Northwind(con);
                var       query =
                    db.Customers.Where(c => c.City == "London" && c.Country == "UK" && c.ContactName == "Thomas Hardy");

                translation = new QueryTranslator().Translate(query.Expression);
            }

            translation.Should().Be("SELECT * FROM (SELECT * FROM Customers) AS T WHERE(((City = 'London') AND (Country = 'UK')) AND (ContactName = 'Thomas Hardy'))");
        }
예제 #2
0
        public void Test_CityTranslation()
        {
            var    translation        = string.Empty;
            string dbConnectionString = @"Server=(localdb)\\mssqllocaldb;Database=Northwind;Trusted_Connection=True;MultipleActiveResultSets=true";

            using (SqlConnection con = new SqlConnection(dbConnectionString))
            {
                Northwind db    = new Northwind(con);
                var       query =
                    db.Customers.Where(c => c.City == "London");

                translation = new QueryTranslator().Translate(query.Expression);
            }

            translation.Should().Be("SELECT * FROM (SELECT * FROM Customers) AS T WHERE(City = 'London')");
        }