diff --git a/README.md b/README.md index f4807256e..7a2763727 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# SqlSugar 4.X +# SqlSugar 4.X API + +3.X https://github.com/sunkaixuan/SqlSugar/tree/master ## 1. Query @@ -132,3 +134,49 @@ var t3 = db.Ado.GetDataTable("select 1 as id"); //db.Ado.GetXXX... ``` +## 2. Insert + ```c +var insertObj = new Student() { Name = "jack", CreateTime = Convert.ToDateTime("2010-1-1") ,SchoolId=1}; + +//Insert reutrn Insert Count +var t2 = db.Insertable(insertObj).ExecuteCommand(); + +//Insert reutrn Identity Value +var t3 = db.Insertable(insertObj).ExecuteReutrnIdentity(); + + +//Only insert Name +var t4 = db.Insertable(insertObj).InsertColumns(it => new { it.Name,it.SchoolId }).ExecuteReutrnIdentity(); + + +//Ignore TestId +var t5 = db.Insertable(insertObj).IgnoreColumns(it => new { it.Name, it.TestId }).ExecuteReutrnIdentity(); + + +//Ignore TestId +var t6 = db.Insertable(insertObj).IgnoreColumns(it => it == "Name" || it == "TestId").ExecuteReutrnIdentity(); + + +//Use Lock +var t8 = db.Insertable(insertObj).With(SqlWith.UpdLock).ExecuteCommand(); + + +var insertObj2 = new Student() { Name = null, CreateTime = Convert.ToDateTime("2010-1-1") }; +var t9 = db.Insertable(insertObj2).Where(true/* Is insert null */, true/*off identity*/).ExecuteCommand(); + +//Insert List +var insertObjs = new List(); +for (int i = 0; i < 1000; i++) +{ + insertObjs.Add(new Student() { Name = "name" + i }); +} +var s9 = db.Insertable(insertObjs.ToArray()).InsertColumns(it => new { it.Name }).ExecuteCommand(); +``` +## 3. Delete + + ```c + ``` + ## 3. Update + + ```c + ```