索引:

目录索引

一.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 条件

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

    以 MySQL 为例,生成 SQL 如下:

 select *
from `agent`
where `ActiveOrderId` is null ;

  2. IS NOT NULL 条件

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

    以 MySQL 为例,生成 SQL 如下:

 select *
from `agent`
where `ActiveOrderId` is not null ;

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

  1. IS NULL 条件

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

    以 MySQL 为例,生成 SQL 如下:

 select *
from `agent`
where `ActiveOrderId` is null ;

  2. IS NOT NULL 条件

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

    以 MySQL 为例,生成 SQL 如下:

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

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

  1. IS NULL 条件

             var res5 = await Conn
.Queryer(out Agent a5,out AgentInventoryRecord r5)
.From(()=>a5)
.LeftJoin(()=>r5)
.On(()=>a5.Id==r5.AgentId)
.Where(() => a5.ActiveOrderId==null)
.QueryListAsync<Agent>();

    以 MySQL 为例,生成 SQL 如下:

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

  2. IS NOT NULL 条件

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

    以 MySQL 为例,生成 SQL 如下:

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

                                         蒙

                                    2019-01-20 22:22 周日

                                    2019-04-12 23:47 周五

MyDAL - is null && is not null 条件 使用的更多相关文章

  1. SQL语句中=null和is null

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

  2. mysql探究之null与not null

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

  3. 【MySQL】探究之null与not null

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

  4. 数据库中is null(is not null)与=null(!=null)的区别

    在标准SQL语言(ANIS SQL)SQL-92规定的Null值的比较取值结果都为False,既Null=Null取值也是False.NULL在这里是一种未知值,千变万化的变量,不是“空”这一个定值! ...

  5. 索引法则--IS NULL, IS NOT NULL 也无法使用索引

    Mysql 系列文章主页 =============== 1 数据准备 1.1 建表 DROP TABLE IF EXISTS staff; CREATE TABLE IF NOT EXISTS st ...

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

    参考连接:https://segmentfault.com/a/1190000009540449 相信很多用了MySQL很久的人,对这两个字段属性的概念还不是很清楚,一般会有以下疑问: 我字段类型是n ...

  7. 数据库表字段,DEFAULT NULL与NOT NULL DEFAULT

    为什么要把字段设置成not null 呢? 1.空值是不占用空间的 2.mysql中的NULL其实是占用空间的,下面是来自于MYSQL官方的解释 “NULL columns require addit ...

  8. 转!!mysql 字段 is not null 和 字段 !=null

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

  9. IOS开发遇到(null)与<null>轻松处理

    在ios开发中不可避免的我们会遇到服务器返回的值有空值,但是如果是nil也就算了还可能得到(null)以及<null>的返回值,该如何处理呢?(当然有的字典转模型中已处理,可以通过遍历等) ...

随机推荐

  1. 【MQ】消息队列及常见MQ比较

    一.什么是消息队列 我们可以把消息队列比作是一个存放消息的容器,当我们需要使用消息的时候可以取出消息供自己使用.消息队列是分布式系统中重要的组件,使用消息队列主要是为了通过异步处理提高系统性能和削峰. ...

  2. 用系统为centos6的主机,搭建PXE服务器,实现批量安装centos6,7系统

    1. iptables -F setenforce 0 临时关掉selinux,清掉防火墙 永久生效更改配置文件:vim /etc/sysconfig/selinux chkconfig iptabl ...

  3. 《Jave并发编程的艺术》学习笔记(1-2章)

    Jave并发的艺术 并发编程的挑战 上下文切换 CPU通过时间片分配算法来循环执行任务,当前时间片执行完之后会切换到下一个任务.但是,切换会保存上一个任务的状态,一遍下次切换回这个任务时,可以再次加载 ...

  4. 使用d3.v5实现折线图与面积图

    d3最新是V5版的,比起V2的API变动了不少,写下我实现过程 效果图: 面积图: 折线图: 目录结构: <!DOCTYPE html> <html lang="en&qu ...

  5. July 07th. 2018, Week 27th. Saturday

    Soon is not as good as now. 别谈未来,现在就行动. From Seth Godin. I always told myself that I should finish w ...

  6. 如何设置织梦cms自定义表单字段为必填项

    1.编辑器打开\plus\diy.php2.在40行左右找到此行代码:$dede_fields = empty($dede_fields) ? '' : trim($dede_fields);3.在这 ...

  7. python之读取配置文件模块configparser(二)参数详解

    configparser.ConfigParser参数详解 从configparser的__ini__中可以看到有如下参数: def __init__(self, defaults=None, dic ...

  8. mysql id从n 开始

    mysql 全部删除数据后设置 id从1开始: truncate table table_name mysql  删除部分数据后设置 id从n开始 ALTER TABLE user auto_incr ...

  9. expect实现自动交互由浅入深

    expect实现自动交互由浅入深 作为运维人员可以通过Shell可以实现简单的控制流功能,如:循环.判断等.但是对于需要交互的场合则必须通过人工来干预,有时候我们可能会需要实现和交互程序如telnet ...

  10. XML的创建、解析-C语言

    前言:今天在做一个小项目时,客户要求的xml,跟现在有系统要求的不一样,所以要自己重新写函数支持返回,进行简单总结,希望对大家有所帮助. 首先,使用xml函数需要链上动态库libxml2,需要在电脑上 ...