索引: 目錄索引 一.API 列表 1.Set<M, F>(Expression<Func<M, F>> propertyFunc, F newVal) 如: .Set(it => it.BodyMeasureProperty, "{xxx:yyy,mmm:nnn,zzz:aaa}") 用於 單表 ...
索引:
一.API 列表
1.Set<M, F>(Expression<Func<M, F>> propertyFunc, F newVal)
如: .Set(it => it.BodyMeasureProperty, "{xxx:yyy,mmm:nnn,zzz:aaa}") 用於 單表 指定欄位更新
2.Set<M>(dynamic filedsObject)
用於 單表 指定多欄位更新
二.API 單表-完整 方法 舉例-01
1 // 多 欄位 多 set 用法 2 var res1 = await Conn 3 .Updater<BodyFitRecord>() // 更新表 BodyFitRecord 4 .Set(it => it.CreatedOn, DateTime.Now) // 設置欄位 CreatedOn 值 5 .Set(it => it.BodyMeasureProperty, "{xxx:yyy,mmm:nnn,zzz:aaa}") // 設置欄位 BodyMeasureProperty 值 6 .Where(it => it.Id == m.Id) 7 .UpdateAsync();
以 MySQL 為例,生成 SQL 如下:
1 update `bodyfitrecord` 2 set `CreatedOn_col`=?CreatedOn_col_1, 3 `BodyMeasureProperty`=?BodyMeasureProperty_2 4 where `Id`=?Id_3;
三.API 單表-完整 方法 舉例-02
1 // 2 var res1 = await Conn 3 .Updater<AgentInventoryRecord>() // 更新表 AgentInventoryRecord 4 .Set(new 5 { 6 TotalSaleCount = 1000, // 更新 欄位 TotalSaleCount 7 xxx = 2000 // 欄位 xxx 在表中無對應 , 自動忽略 8 }) 9 .Where(it => it.Id == Guid.Parse("032ce51f-1034-4fb2-9741-01655202ecbc")) 10 .UpdateAsync();
以 MySQL 為例,生成 SQL 如下:
1 update `agentinventoryrecord` 2 set `TotalSaleCount`=?TotalSaleCount_1 3 where `Id`=?Id_2;
四.API 單表-完整 方法 舉例-03
1 // 要更新的 model 欄位 賦值 2 var model = new AgentInventoryRecord(); 3 model.TotalSaleCount = 1000; 4 5 // 6 var res1 = await Conn 7 .Updater<AgentInventoryRecord>() //更新表 AgentInventoryRecord 8 .Set(new 9 { 10 model.TotalSaleCount, // 更新 欄位 TotalSaleCount 11 xxx = 2000 // 欄位 xxx 在表中無對應 ,自動忽略 12 }) 13 .Where(it => it.Id == Guid.Parse("032ce51f-1034-4fb2-9741-01655202ecbc")) 14 .UpdateAsync();
以 MySQL 為例,生成 SQL 如下:
1 update `agentinventoryrecord` 2 set `TotalSaleCount`=?TotalSaleCount_1 3 where `Id`=?Id_2;
蒙
2019-04-12 17:27 周五