介绍一些我尝试的mysqlSugar的数据库操作 修改密码 var status = db.Update<Users>(new { password = user.password }, it => it.username == user.username); 更新数据(防止空值一起更新) 首先封装一个函数(判断是否为空或者数值为0),当然sqlsugar有自己的查询函数,判断值不为空且大于0 SqlFunc.HasNumber(object thisValue) public voi
1.insert 不论你设置多少个字段,统一都要添加一遍 比如:insert into tb_user (id,name,age,password) value (null,”张三”,null,null): insertSelective 选择性插入,只插入有数据的 比如:insert into tb_user (id,name) value (null,”张三”): 2. updateByPrimaryKeySelective updateByPrimaryKey 前者只是更新新的model中
$_ 有好几个功能,我们最常用的是用它来获取“刚刚执行过的命令的最后一个参数”这个功能,比如下面这样: $ ls ~/Downloads/very/long/dir/ # ls 到某个目录看看有没有我们想要的文件 file1 file2 needed_file $ cd $_ # 如果有,就进入到那个文件夹,$_ 让你省去了不少键盘敲击数 Bash manual 中对 $_ 的这个功能的描述只有一句话: expands to the last argument to the previous