当前位置: 移动技术网 > IT编程>开发语言>.net > MyDAL - .UpdateAsync() 之 .Set() 使用

MyDAL - .UpdateAsync() 之 .Set() 使用

2019年04月13日  | 移动技术网IT编程  | 我要评论

皇家四号恶魔校草全文免费阅读,msdtssrvr.exe,中通物流电话

索引:

一.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 周五

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网