public void Empty_List()
        {
            IValList list = sql.ValList;

            Exception ex = Assert.Throws <CompileException>(() => engine.Compile(list));

            Assert.Equal("List is empty.", ex.Message);
        }
示例#2
0
        public void Null_Value_Expression_Inline()
        {
            IValList valList = sql.ValList.Add(() => null);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
示例#3
0
        public void Null_Value()
        {
            string   value   = null;
            IValList valList = sql.ValList.Add(value);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("NULL", result.Sql);
            Assert.Equal(new Dictionary <string, object>(), result.Parameters);
        }
示例#4
0
        public void To_String()
        {
            IAlias   person = sql.Alias("person");
            IValList list   = sql.ValList
                              .Add(person["Id"])
                              .Add(1)
                              .Add("text");

            Assert.Equal("person.Id, 1, \"text\"", list.ToString());
        }
示例#5
0
        public void DateTime_Value_Expression_Inline()
        {
            IValList valList = sql.ValList.Add(() => new DateTime(2000, 1, 1));

            QueryResult result = engine.Compile(valList);

            Assert.Equal("@p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = new DateTime(2000, 1, 1)
            }, result.Parameters);
        }
示例#6
0
        public void String_Value_Expression_Inline()
        {
            IValList valList = sql.ValList.Add(() => "abcd");

            QueryResult result = engine.Compile(valList);

            Assert.Equal("@p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = "abcd"
            }, result.Parameters);
        }
示例#7
0
        public void Int32_Value()
        {
            int      value   = 1;
            IValList valList = sql.ValList.Add(value);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("@p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = value
            }, result.Parameters);
        }
示例#8
0
        public void Array_Value_Expression_Inline_With_Null()
        {
            IValList valList = sql.ValList.Add(() => new string[] { "a", null, "c" });

            QueryResult result = engine.Compile(valList);

            Assert.Equal("(@p0, NULL, @p1)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = "a",
                ["@p1"] = "c"
            }, result.Parameters);
        }
示例#9
0
        public void DateTime_Value_Expression()
        {
            DateTime value   = DateTime.Now;
            IValList valList = sql.ValList.Add(() => value);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("@p0", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = value
            }, result.Parameters);
        }
示例#10
0
        public void Add_Expression_Params()
        {
            Person   person = null;
            IValList list   = sql.ValList.Add(() => person.Id, () => 1, () => "text");

            QueryResult result = engine.Compile(list);

            Assert.Equal("\"person\".\"Id\", @p0, @p1", engine.Compile(list).Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = 1, ["@p1"] = "text"
            }, result.Parameters);
        }
示例#11
0
        public void Add_Params()
        {
            IAlias   person = sql.Alias("person");
            IValList list   = sql.ValList.Add(person["Id"], 1, "text");

            QueryResult result = engine.Compile(list);

            Assert.Equal("\"person\".\"Id\", @p0, @p1", engine.Compile(list).Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = 1, ["@p1"] = "text"
            }, result.Parameters);
        }
示例#12
0
        public void Array_Value_Expression_Inline()
        {
            IValList valList = sql.ValList.Add(() => new int[] { 1, 2, 3 });

            QueryResult result = engine.Compile(valList);

            Assert.Equal("(@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = 1,
                ["@p1"] = 2,
                ["@p2"] = 3
            }, result.Parameters);
        }
示例#13
0
        public void Array_Value_With_Null()
        {
            string[] values  = new string[] { "a", null, "c" };
            IValList valList = sql.ValList.Add((object)values);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("(@p0, NULL, @p1)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = values[0],
                ["@p1"] = values[2]
            }, result.Parameters);
        }
示例#14
0
        public void Array_Value_Expression()
        {
            int[]    values  = new int[] { 1, 2, 3 };
            IValList valList = sql.ValList.Add(() => values);

            QueryResult result = engine.Compile(valList);

            Assert.Equal("(@p0, @p1, @p2)", result.Sql);
            Assert.Equal(new Dictionary <string, object>()
            {
                ["@p0"] = values[0],
                ["@p1"] = values[1],
                ["@p2"] = values[2]
            }, result.Parameters);
        }
示例#15
0
 /// <summary>
 /// Adds a "partition by" clause.
 /// </summary>
 /// <param name="partitionBy">The list of columns.</param>
 /// <returns>The "over" clause.</returns>
 public virtual IOver PartitionBy(IValList partitionBy)
 {
     PartitionByValue = partitionBy;
     return(this);
 }