This commit is contained in:
sunkaixuan 2023-05-21 18:13:43 +08:00
parent 335f9bd690
commit 45ff6d39ff
3 changed files with 22 additions and 5 deletions

View File

@ -55,6 +55,16 @@ namespace OrmTest
var result6 = db.Updateable(updateObjs).WhereColumns(it => new { it.Id }).ExecuteCommand();//update List<Class> by id
var list = db.Queryable<Order>().OrderBy(it => it.Id).Take(2).ToList();
if (list.Count >= 2)
{
list[0].Price = 10;
list[1].Price = 2;
var result69 =
db.Updateable(list)
.PublicSetColumns(it => it.Price, "+")
.ExecuteCommand();
}
/*** 2.by expression ***/

View File

@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugarCore</id>
<version>5.1.4.73</version>
<version>5.1.4.77-preview02</version>
<authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

View File

@ -53,10 +53,17 @@ namespace OrmTest
//If there is no primary key
var result5 = db.Updateable(updateObj).WhereColumns(it => new { it.Id }).ExecuteCommand();//update single by id
var result6 = db.Updateable(updateObjs).WhereColumns(it => new { it.Id }).ExecuteCommand();//update List<Class> by id
var list = db.Queryable<Order>().OrderBy(it => it.Id).Take(2).ToList();
if (list.Count >= 2)
{
list[0].Price = 10;
list[1].Price = 2;
var result69 =
db.Updateable(list)
.PublicSetColumns(it => it.Price, "+")
.ExecuteCommand();
}
/*** 2.by expression ***/
//update name,createtime