Esempio n. 1
0
        public void MethodVarTest(int value)
        {
            Expression<Func<GracefulTestModel, bool>> expression =
                e => e.Bar == value;

            var converter = new LikeConverter();
            converter.Visit(expression.Body);

            Assert.Equal("([Bar] LIKE {0})", converter.Sql);
            Assert.Equal(new object[] {123}, converter.Parameters);
        }
Esempio n. 2
0
        public void AndTest()
        {
            Expression<Func<GracefulTestModel, bool>> expression =
                e => e.Foo == "Hello" && e.Bar == 123;

            var converter = new LikeConverter();
            converter.Visit(expression.Body);

            Assert.Equal("(([Foo] LIKE {0}) AND ([Bar] LIKE {1}) )", converter.Sql);
            Assert.Equal(new object[] {"Hello", 123}, converter.Parameters);
        }
Esempio n. 3
0
        public void BasicTest()
        {
            Expression<Func<GracefulTestModel, bool>> expression =
                e => e.Foo == "Hello";

            var converter = new LikeConverter();
            converter.Visit(expression.Body);

            Assert.Equal("([Foo] LIKE {0})", converter.Sql);
            Assert.Equal(new object[] {"Hello"}, converter.Parameters);
        }
Esempio n. 4
0
        private void MethodVarObjectTestPrvate(Models.CustomContext entity)
        {
            Expression<Func<Models.CustomContext, bool>> expression =
                e => e.Foo == entity.Foo;

            var converter = new LikeConverter();
            converter.Visit(expression.Body);

            Assert.Equal("([Foo] LIKE {0})", converter.Sql);
            Assert.Equal(new object[] { "Bar" }, converter.Parameters);
        }