mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-27 10:25:47 +08:00
- 增加 fsql.Insert(Dictionary<string, object>) 无实体类插入方法;#481
This commit is contained in:
@@ -22,6 +22,37 @@ namespace FreeSql.Tests.Oracle
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void InsertDictionary()
|
||||
{
|
||||
var fsql = g.oracle;
|
||||
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 ALL
|
||||
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(:id_0, :name_0)
|
||||
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(:id_1, :name_1)
|
||||
SELECT 1 FROM DUAL", 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 ALL
|
||||
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(1, 'xxxx')
|
||||
INTO ""TABLE1""(""ID"", ""NAME"") VALUES(2, 'yyyy')
|
||||
SELECT 1 FROM DUAL", sql4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AppendData()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user