public void Empty_List() { IValList list = sql.ValList; Exception ex = Assert.Throws <CompileException>(() => engine.Compile(list)); Assert.Equal("List is empty.", ex.Message); }
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); }
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); }
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()); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
/// <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); }