- 增加 fsql.Insert(Dictionary<string, object>) 无实体类插入方法;#481

This commit is contained in:
2881099
2022-03-24 18:06:54 +08:00
parent 56ce675b65
commit dc688adc11
47 changed files with 416 additions and 80 deletions

View File

@@ -22,6 +22,35 @@ namespace FreeSql.Tests.Firebird
public DateTime CreateTime { get; set; }
}
[Fact]
public void InsertDictionary()
{
var fsql = g.firebird;
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("id", 1);
dic.Add("name", "xxxx");
var diclist = new List<Dictionary<string, object>>();
diclist.Add(dic);
diclist.Add(new Dictionary<string, object>
{
["id"] = 2,
["name"] = "yyyy"
});
var sql1 = fsql.Insert(dic).AsTable("table1").ToSql();
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") VALUES(@id_0, @name_0)", sql1);
var sql2 = fsql.Insert(diclist).AsTable("table1").ToSql();
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") SELECT FIRST 1 @id_0, @name_0 FROM rdb$database
UNION ALL
SELECT FIRST 1 @id_1, @name_1 FROM rdb$database", sql2);
var sql3 = fsql.Insert(dic).AsTable("table1").NoneParameter().ToSql();
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") VALUES(1, 'xxxx')", sql3);
var sql4 = fsql.Insert(diclist).AsTable("table1").NoneParameter().ToSql();
Assert.Equal(@"INSERT INTO ""TABLE1""(""ID"", ""NAME"") SELECT FIRST 1 1, 'xxxx' FROM rdb$database
UNION ALL
SELECT FIRST 1 2, 'yyyy' FROM rdb$database", sql4);
}
[Fact]
public void AppendData()
{