Exemple #1
0
        public void Expression_Method_Invalid_Call()
        {
            Person person = new Person();

            Exception ex = Assert.Throws <InvalidOperationException>(() => SqlExp.Like(person.Name, "%SomeName%"));

            Assert.Equal("Only for expressions.", ex.Message);
        }
Exemple #2
0
        public void Expression_Method_Null()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Name, null));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" LIKE NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Exemple #3
0
        public void Expression_Method_Column()
        {
            Person2     person = null;
            Department2 dept   = null;
            IOperator   op     = sql.Op(() => SqlExp.Like(person.Department.Guid, dept.Guid));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentGuid\" LIKE \"dept\".\"Guid\"", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
Exemple #4
0
        public void Expression_Method_Enumerable()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Image, new byte[] { 1, 2, 3 }));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Image\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = new byte[] { 1, 2, 3 }
            }, result.Parameters);
        }
Exemple #5
0
        public void Expression_Method()
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Name, "%SomeName%"));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Name\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = "%SomeName%"
            }, result.Parameters);
        }
Exemple #6
0
        public void Expression_Method_List <T>(List <T> value)
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.Like(dept.Tags, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"dept\".\"Tags\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Exemple #7
0
        public void Expression_Method_Array <T>(T[] value)
        {
            Person    person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Image, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"Image\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Exemple #8
0
        public void Expression_Method_Nested_Deep(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Address.City.Country.Name, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"AddressCityCountryName\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Exemple #9
0
        public void Expression_Method_ForeignKey(object value)
        {
            Person2   person = null;
            IOperator op     = sql.Op(() => SqlExp.Like(person.Department.Guid, value));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"person\".\"DepartmentGuid\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = value
            }, result.Parameters);
        }
Exemple #10
0
        public void Expression_Method_List_Inline_Value()
        {
            Department dept = null;
            IOperator  op   = sql.Op(() => SqlExp.Like(dept.Tags, new List <string> {
                "abcd", "efgh", "ijkl"
            }));

            QueryResult result = engine.Compile(op);

            Assert.Equal("\"dept\".\"Tags\" LIKE @p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>
            {
                ["@p0"] = new List <string> {
                    "abcd", "efgh", "ijkl"
                }
            }, result.Parameters);
        }