索引:

目录索引

一.API 列表

  C# 代码中 instance.property == null 生成 SQL 对应的 is null

    :.Queryer<Agent>()

      ... ...

      .Where(it => it.CrmUserId == null)

      ... ... 用于 单表 is null 条件

      .Queryer(out Agent a5,out AgentInventoryRecord r5)

      ... ...

      .Where(() => a5.ActiveOrderId==null)

      ... ... 用于 多表连接 is null 条件

  C# 代码中 instance.propery != null 生成 SQL 对应的 is not null

    如:.Queryer<Agent>()

      ... ...

      .Where(it => it.ActiveOrderId != null)

      ... ... 用于 单表 is not null 条件

      .Queryer(out Agent a6, out AgentInventoryRecord r6)

      ... ...

      .Where(() => a6.ActiveOrderId != null)

      ... ... 用于 多表连接 is not null 条件

二.API 单表-便捷 方法 举例

  1. IS NULL 条件

1             var res7 = await Conn.QueryListAsync<Agent>(it => it.ActiveOrderId == null);

    以 MySQL 为例,生成 SQL 如下:

1 select *
2 from `agent`
3 where  `ActiveOrderId`  is null ;

  2. IS NOT NULL 条件

1             var res8 = await Conn.QueryListAsync<Agent>(it => it.ActiveOrderId != null);

    以 MySQL 为例,生成 SQL 如下:

1 select *
2 from `agent`
3 where  `ActiveOrderId`  is not null ;

三.API 单表-完整 方法 举例

  1. IS NULL 条件

1             var res1 = await Conn
2                 .Queryer<Agent>()
3                 .Where(it => it.ActiveOrderId == null)
4                 .QueryListAsync();

    以 MySQL 为例,生成 SQL 如下:

1 select *
2 from `agent`
3 where  `ActiveOrderId`  is null ;

  2. IS NOT NULL 条件

1             var res4 = await Conn
2                 .Queryer<Agent>()
3                 .Where(it => it.ActivedOn != null && it.ActiveOrderId != null && it.CrmUserId == null)
4                 .QueryListAsync();

    以 MySQL 为例,生成 SQL 如下:

1 select *
2 from `agent`
3 where (( `ActivedOn`  is not null  &&  `ActiveOrderId`  is not null ) &&  `CrmUserId`  is null );

四.API 多表连接-完整 方法 举例

  1. IS NULL 条件

1             var res5 = await Conn
2                 .Queryer(out Agent a5,out AgentInventoryRecord r5)
3                 .From(()=>a5)
4                     .LeftJoin(()=>r5)
5                         .On(()=>a5.Id==r5.AgentId)
6                 .Where(() => a5.ActiveOrderId==null)
7                 .QueryListAsync<Agent>();

    以 MySQL 为例,生成 SQL 如下:

1 select a5.`*`
2 from `agent` as a5
3     left join `agentinventoryrecord` as r5
4         on a5.`Id`=r5.`AgentId`
5 where  a5.`ActiveOrderId`  is null ;

  2. IS NOT NULL 条件

1             var res6 = await Conn
2                 .Queryer(out Agent a6, out AgentInventoryRecord r6)
3                 .From(() => a6)
4                     .LeftJoin(() => r6)
5                         .On(() => a6.Id == r6.AgentId)
6                 .Where(() => a6.ActiveOrderId != null)
7                 .QueryListAsync<Agent>();

    以 MySQL 为例,生成 SQL 如下:

1 select a6.`*`
2 from `agent` as a6
3     left join `agentinventoryrecord` as r6
4         on a6.`Id`=r6.`AgentId`
5 where  a6.`ActiveOrderId`  is not null ;

                                         蒙

                                    2019-01-20 22:22 周日

                                    2019-04-12 23:47 周五

转载于:https://www.cnblogs.com/Meng-NET/p/10296445.html

MyDAL - is null is not null 条件 使用相关推荐

  1. null=null不能作为关联条件

    null=null不能作为关联条件,用在on后面 测试 SELECT NULL=NULL; SELECT NULL<>NULL; 从上面可以看出null=null和null<> ...

  2. Mysql探究之null与not null

    相信很多用了mysql很久的人,对这两个字段属性的概念还不是很清楚,一般会有以下疑问: 1.我字段类型是not null,为什么我可以插入空值 2.为毛not null的效率比null高 3.判断字段 ...

  3. mysql中的钱null,mysql 中null总结

    ====================== 相信很多用了mysql很久的人,对这两个字段属性的概念还不是很清楚,一般会有以下疑问: 1.我字段类型是not null,为什么我可以插入空值 2.为毛n ...

  4. mysql not is null_转!!mysql 字段 is not null 和 字段 !=null

    今天在查询数据时,查到包含一条某个时间startTime(该字段默认为null ) 为null的记录,想把它过滤,加了 startTime!= null 的条件,结果记录都没了,应该用条件 is no ...

  5. SQL语句中=null和is null

    平时经常会遇到这两种写法:IS NOT NULL与!=NULL.也经常会遇到数据库有符合条件!=NULL的数据,但是返回为空集合.实际上,是由于对二者使用区别理解不透彻. 默认情况下,推荐使用 IS ...

  6. MySQL null与not null和null与空值‘‘的区别

    null 表示什么也不是, 不能=.>.< - 所有的判断,结果都是false,所有只能用 is null进行判断. 转自:https://segmentfault.com/a/11900 ...

  7. 错误记录(11): source is null for getProperty(null, name)

    使用SSM框架做项目时,使用到了XML中的判断条件查询方式,代码如下: <if test="machineInfo.name != null and machineInfo.name ...

  8. mysql null 0 空_MySQL中 null与not null和null与空值''的区别

    相信很多用了MySQL很久的人,对这两个字段属性的概念还不是很清楚,一般会有以下疑问: 1.字段类型是not null,为什么可以插入空值? 2.为什么not null的效率比null高? 3.判断字 ...

  9. mysql 的 null值_MySQL NULL值

    我们已经看到SQL SELECT命令和WHERE子句一起使用,来从MySQL表中提取数据,但是,当我们试图给出一个条件,比较字段或列值设置为NULL,它确不能正常工作. 为了处理这种情况,MySQL提 ...

最新文章

  1. Cors 跨域Access-Control-Allow-Origin
  2. 6月24 面向对象的设计原则-----工厂模式和单列模式
  3. Java—实现 IOC 功能的简单 Spring 框架
  4. CSP-J NOIP NOI数学与动态规划
  5. 45.国际化-选择使用资源文件
  6. 跨进程的 键盘钩子_Delphi下深入Windows编程之钩子原理一
  7. assertion: 18 { code: 18, ok: 0.0, errmsg: auth fails }
  8. C++访问WebService
  9. PHP微信公众开发笔记(九)
  10. What are FeliCa and PaSoRi?
  11. 干货~~牛人教你如何写好一篇高分SCI论文
  12. 破解iOS微信骰子和猜拳
  13. Windows7操作系统下的修改屏幕旋转快捷键
  14. 试用期程序员应该了解的事儿
  15. 虚拟机Ubuntu中编写C语言程序
  16. 有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个人岁数,他说比第3个人大2岁。问第三个人,又说比第2人大两岁。问第2个人,说比第一个人大两岁。最后问第一个人,他说是10岁。请问第五个
  17. python基础语法Day11
  18. 计算机导论11.29课后总结
  19. 小程序毕业设计 基于java后台微信在线视频点播小程序毕业设计参考
  20. scrapy 爬取https网页时出现ssl错误

热门文章

  1. 管理系统统一鉴权服务器,确认服务器已启用密码鉴权
  2. jquery修改样式通过类
  3. 计算机重启恢复到推荐分辨率,为什么重启之后电脑界面分辨率会变
  4. oracle查看所有用户6,oracle 查看 用户 用户权限 用户表空间 用户默认表空间
  5. The CC version check failed下出现Failed CC version check. Bailing out! 解决方案
  6. Github上如何找到自己想要的开源项目(小技巧:精确搜索)
  7. C#基础7:类的定义
  8. Wannafly挑战赛9: B. 数一数
  9. os.path.basename()
  10. 01背包问题笔记(转载)