public void MethodVarTest(int value) { Expression<Func<GracefulTestModel, bool>> expression = e => e.Bar == value; var converter = new PredicateConverter(); converter.Visit(expression.Body); Assert.Equal("([Bar] = {0})", converter.Sql); Assert.Equal(new object[] {123}, converter.Parameters); }
public void AndTest() { Expression<Func<GracefulTestModel, bool>> expression = e => e.Foo == "Hello" && e.Bar == 123; var converter = new PredicateConverter(); converter.Visit(expression.Body); Assert.Equal("(([Foo] = {0}) AND ([Bar] = {1}) )", converter.Sql); Assert.Equal(new object[] {"Hello", 123}, converter.Parameters); }
public void BasicTest() { Expression<Func<GracefulTestModel, bool>> expression = e => e.Foo == "Hello"; var converter = new PredicateConverter(); converter.Visit(expression.Body); Assert.Equal("([Foo] = {0})", converter.Sql); Assert.Equal(new object[] {"Hello"}, converter.Parameters); }
public void NotNullTest() { Expression<Func<GracefulTestModel, bool>> expression = e => e.Foo != null; var converter = new PredicateConverter(); converter.Visit(expression.Body); Assert.Equal("([Foo] IS NOT NULL)", converter.Sql); Assert.Equal(new object[] {}, converter.Parameters); }
private void MethodVarObjectTestPrvate(Models.CustomContext entity) { Expression<Func<Models.CustomContext, bool>> expression = e => e.Foo == entity.Foo; var converter = new PredicateConverter(); converter.Visit(expression.Body); Assert.Equal("([Foo] = {0})", converter.Sql); Assert.Equal(new object[] { "Bar" }, converter.Parameters); }