索引:

目录索引

一.API 列表

  .QueryListAsync()

  .QueryListAsync<M>()

    如: .QueryListAsync<AgentInventoryRecord>() , 用于 单表/多表连接 查询.

  .QueryListAsync<VM>()

    如: .QueryListAsync<AgentVM>() , 用于 单表 查询.

  .QueryListAsync<T>(Expression<Func<M, T>> columnMapFunc)

    如: .QueryListAsync(it => it.Name) , 用于 单表 单列 查询.

    或者:

      .QueryListAsync(agent => new AgentVM
                  {
                      XXXX = agent.Name,
                      YYYY = agent.PathId
                  })  , 用于 单表 多列 查询.

  .QueryListAsync<T>(Expression<Func<T>> columnMapFunc)

    如:  .Queryer(out Agent agent1, out AgentInventoryRecord record1)

      ... ...

      .QueryListAsync(() => agent1.CreatedOn)   , 用于 多表连接 单列 查询.

    或者: .Queryer(out Agent agent12, out AgentInventoryRecord record12)

        ... ...

       .QueryListAsync(() => new AgentVM
                  {
                      nn = agent12.PathId,
                      yy = record12.Id,
                      xx = agent12.Id,
                      zz = agent12.Name,
                      mm = record12.LockedCount
                  })  , 用于 多表连接 多列 查询.

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

  1. 单表 单列 多条 便捷方法 

             var res7 = await Conn.QueryListAsync<Agent, string>(it => it.Name.StartsWith("张"), it => it.Name);

    以 MySQL 为例,生成 SQL 如下:

 select `Name`
from `Agent`
where `Name` like ?Name_1;

  2. 单表 多列 多条 便捷方法

        var date = DateTime.Parse("2018-08-20");

             var res3 = await Conn.QueryListAsync<AlipayPaymentRecord, AlipayPaymentRecordVM>(it => it.CreatedOn >= date,
it => new AlipayPaymentRecordVM
{
TotalAmount = it.TotalAmount,
Description = it.Description
});

    以 MySQL 为例,生成 SQL 如下:

 select     `TotalAmount` as TotalAmount,
    `Description` as Description
from `AlipayPaymentRecord`
where `CreatedOn`>=?CreatedOn_1;

  3. 单表 VM 多条 便捷方法

             var date = DateTime.Parse("2018-08-20");

             var res2 = await Conn.QueryListAsync<AlipayPaymentRecord, AlipayPaymentRecordVM>(it => it.CreatedOn >= date);

    以 MySQL 为例,生成 SQL 如下:

 select     `Id`,
`CreatedOn`,
`TotalAmount`,
`Description`,
`CanceledOn`
from `AlipayPaymentRecord`
where `CreatedOn`>=?CreatedOn_1;

  4. 单表 M 多条 便捷方法

             var date = DateTime.Parse("2018-08-20");

             var res1 = await Conn.QueryListAsync<AlipayPaymentRecord>(it => it.CreatedOn >= date);

    以 MySQL 为例,生成 SQL 如下:

 select *
from `AlipayPaymentRecord`
where `CreatedOn`>=?CreatedOn_1;

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

  1. 单表 单列 多条 完整方法

             var res2 = await Conn
.Queryer<Agent>()
.Where(it => it.AgentLevel == AgentLevel.DistiAgent)
.QueryListAsync(it => it.Name);

    以 MySQL 为例,生成 SQL 如下:

 select `Name`
from `Agent`
where `AgentLevel`=?AgentLevel_1;

  2.单表 多列 多条 完整方法

             var res5 = await Conn
.Queryer<Agent>()
.Where(it => it.AgentLevel == AgentLevel.DistiAgent)
.QueryListAsync(agent => new AgentVM
{
XXXX = agent.Name,
YYYY = agent.PathId
});

    以 MySQL 为例,生成 SQL 如下:

 select     `Name` as XXXX,
`PathId` as YYYY
from `Agent`
where `AgentLevel`=?AgentLevel_1;

  3.单表 VM 多条 完整方法

             var testQ5 = new WhereTestModel
{
CreatedOn = DateTime.Now.AddDays(-),
StartTime = WhereTest.CreatedOn,
EndTime = DateTime.Now,
AgentLevelXX = AgentLevel.DistiAgent,
ContainStr = "~00-d-3-1-"
};
var res5 = await Conn
.Queryer<Agent>()
.Where(it => it.CreatedOn >= testQ5.StartTime)
.QueryListAsync<AgentVM>();

    以 MySQL 为例,生成 SQL 如下:

 select     `Id`,
`CreatedOn`,
`UserId`,
`PathId`,
`Name`,
`Phone`
from `Agent`
where `CreatedOn`>=?CreatedOn_1;

  4. 单表 M 多条 完整方法

             var start = WhereTest.CreatedOn.AddDays(-);

             var res2 = await Conn
.Queryer<BodyFitRecord>()
.Where(it => it.CreatedOn >= start)
.QueryListAsync();

    以 MySQL 为例,生成 SQL 如下:

 select *
from `BodyFitRecord`
where `CreatedOn`>=?CreatedOn_1;

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

  1.多表连接 单列 多条 完整方法

             var res1 = await Conn
.Queryer(out Agent agent1, out AgentInventoryRecord record1)
.From(() => agent1)
.InnerJoin(() => record1)
.On(() => agent1.Id == record1.AgentId)
.Where(() => agent1.AgentLevel == AgentLevel.DistiAgent)
.QueryListAsync(() => agent1.CreatedOn);

    以 MySQL 为例,生成 SQL 如下:

 select agent1.`CreatedOn`
from `Agent` as agent1
inner join AgentInventoryRecord as record1
on agent1.`Id`=record1.`AgentId`
where agent1.`AgentLevel`=?AgentLevel_4;

  2.多表连接 多列 多条 完整方法

             var res12 = await Conn
.Queryer(out Agent agent12, out AgentInventoryRecord record12)
.From(() => agent12)
.InnerJoin(() => record12)
.On(() => agent12.Id == record12.AgentId)
.Where(() => record12.CreatedOn >= WhereTest.CreatedOn)
.QueryListAsync(() => new AgentVM
{
nn = agent12.PathId,
yy = record12.Id,
xx = agent12.Id,
zz = agent12.Name,
mm = record12.LockedCount
});

    以 MySQL 为例,生成 SQL 如下:

 select     agent12.`PathId` as nn,
record12.`Id` as yy,
agent12.`Id` as xx,
agent12.`Name` as zz,
record12.`LockedCount` as mm
from `Agent` as agent12
inner join AgentInventoryRecord as record12
on agent12.`Id`=record12.`AgentId`
where record12.`CreatedOn`>=?CreatedOn_4;

  3.多表连接 M 多条 完整方法

             var res1 = await Conn
.Queryer(out Agent agent1, out AgentInventoryRecord record1)
.From(() => agent1)
.InnerJoin(() => record1)
.On(() => agent1.Id == record1.AgentId)
.Where(() => agent1.CreatedOn >= WhereTest.CreatedOn.AddDays(-))
.QueryListAsync<AgentInventoryRecord>();

    以 MySQL 为例,生成 SQL 如下:

 select record1.`*`
from `Agent` as agent1
inner join AgentInventoryRecord as record1
on agent1.`Id`=record1.`AgentId`
where agent1.`CreatedOn`>=?CreatedOn_4;

                                         蒙

                                    2018-12-26 15:25 周三

                                    2018-12-30 11:30 周日

                                    2019-04-12 23:29 周五

MyDAL - .QueryListAsync() 使用的更多相关文章

  1. MyDAL - 快速使用

    索引: 目录索引 一.安装 在 VS 中执行一下 package 命令: PM> Install-Package MyDAL 二.API-快速使用 1.命名空间,只需: using MyDAL; ...

  2. MyDAL - .Where() 之 .WhereSegment 根据条件 动态设置 Select查询条件 使用

    索引: 目录索引 一.API 列表 1.WhereSegment 属性,指示 根据条件 动态拼接 where 查询过滤条件 见如下示例. 二.API 单表-完整 方法 举例 // 上下文条件 变量 v ...

  3. MyDAL - 引用类型对象 .DeepClone() 深度克隆[深度复制] 工具 使用

    索引: 目录索引 一.API 列表 .DeepClone() 用于 Model / Entity / ... ... 等引用类型对象的深度克隆 特性说明 1.不需要对对象做任何特殊处理,直接 .Dee ...

  4. MyDAL - in && not in 条件 使用

    索引: 目录索引 一.API 列表 C# 代码中 接口 IList.Contains() 方法生成 SQL 对应的 in(val1,val2,... ...) 如:.Queryer<Agent& ...

  5. MyDAL - like && not like 条件 使用

    索引: 目录索引 一.API 列表 C# 代码中 String.Contains("conditionStr") 生成 SQL 对应的 like '%conditionStr%' ...

  6. MyDAL - 组件适用范围说明

    索引: 目录索引 一.组件特性简介: 1.MSIL 底层代码采用 System.Reflection.Emit.Lightweight 类库使用 IL 的方式处理 Model 组装,性能刚刚的~ 2. ...

  7. MyDAL - is null && is not null 条件 使用

    索引: 目录索引 一.API 列表 C# 代码中 instance.property == null 生成 SQL 对应的 is null : 如:.Queryer<Agent>() .. ...

  8. MyDAL - .Where() & .And() & .Or() 使用

    索引: 目录索引 一.API 列表 1.Where .Where(Func<M, bool> func) 如: .Where( it => (it.Prop1>=条件1 &am ...

  9. MyDAL - .OpenDebug() 与 Visual Studio 输出窗口 使用

    索引: 目录索引 SQL Debug 信息说明 一. 对 XConnection 对象 未开启 OpenDebug, 在 VS  状态下,将默认在 VS 窗口 打印出 参数化的 SQL 执行语句: 新 ...

随机推荐

  1. 也谈Reactor模式

    何谓Reactor模式?它是实现高性能IO的一种设计模式.网上资料有很多,有些写的也很好,但大多不知其所以然.这里博主按自己的思路简单介绍下,有不对的地方敬请指正. BIO Java1.4(2002年 ...

  2. PBFT概念与Go语言入门(Tendermint基础)

    Tendermint作为当前最知名且实用的PBFT框架,网上资料并不很多,而实现Tendermint和以太坊的Go语言,由于相对小众,也存在资料匮乏和模糊错漏的问题.本文简单介绍PBFT概念和Go语言 ...

  3. ES6数组扩展运算符

    1 扩展运算符的运用 (1)复制数组 数组是复合的数据类型,直接复制的话,只是复制了指向底层数据机构的指针,而不是克隆一个全新的数组; const a1=[1,2]; const a2= a1; a2 ...

  4. Oracle数据库知识要点

    一.卸载安装(来自百度经验) 完全卸载: 1. 停止相关服务 2. 运行Universal Installer,卸载产品 3. 清理注册表 4. 重启电脑,删除目录(Oracle文件夹和app文件夹) ...

  5. vue表格实现固定表头首列

    前言 最近在做vue移动端项目,需要做一个可以固定表头首列的表格,而且由于一些原因不能使用任何UI插件,网上找了很久也没什么好方法,所以在解决了问题之后,写下了这篇文章供后来人参考,文章有什么错漏的问 ...

  6. 驰骋工作流引擎-流程数据md5加密

    关键字:工作流程数据加密  md5  数据保密流程数据防篡改软加密设置方式: 对工作流引擎的数据加密研究, 流程数据的加密方案与实现过程.输入图片说明需求背景1, 流程数据加密是为了防止流程数据被篡改 ...

  7. SQL Server2008 xp_cmdshell啟用

    1. 查看系统数据库参数配置: select * from sys.configurations where name='xp_cmdshell' 修改系统数据库参数:   语法格式:     sp_ ...

  8. 开发vue但不使用vue-cli和webpack相关注意事项

    1.绑定vue组件使用new Vue() 2.new Vue()需要在dom结构生成之后才有效(毕竟有需要el) 3.Vue.component注册全局组件在vue容器组件挂载之前才有效 4.当然,可 ...

  9. Java相关面试题总结+答案(三)

    [多线程] 35. 并行和并发有什么区别? 并行:多个处理器或多核处理器同时处理多个任务.(是真正的物理上的同时发生) 并发:多个任务在同一个 CPU 核上,按细分的时间片轮流(交替)执行,从逻辑上来 ...

  10. Jason Wang:记录自己所想所得(第一次作业)

    这个作业属于哪个课程 <课程的链接> 这个作业要求在哪里 <作业要求的链接> 我在这个课程的目标是 学会现代软件工程的思想,运用到实际中去 这个作业在哪个具体方面帮助我实现目标 ...