索引:
一.API 列表
.IsExistAsync()
用于 单表 / 多表连接 查询
二.API 单表-便捷 方法 举例
1.单表-便捷, 判断是否存在方法
var date = DateTime.Parse("2018-08-20 20:33:21.584925");
var id = Guid.Parse("89c9407f-7427-4570-92b7-0165590ac07e"); // 判断 AlipayPaymentRecord 表中是否存在符合条件的数据
bool res1 = await Conn.IsExistAsync<AlipayPaymentRecord>(it => it.CreatedOn == date && it.OrderId == id);
以 MySQL 为例,生成 SQL 如下, 在返回结果时 IsExistAsync API 中会判断结果是否 >0 ,返回 true or false :
select count(*)
from `AlipayPaymentRecord`
where ( `CreatedOn`=?CreatedOn_2 && `OrderId`=?OrderId_3);
三.API 单表-完整 方法 举例
1.单表-完整, 判断是否存在方法
var pk2 = Guid.Parse("002c1ca9-f2df-453a-87e0-0165443dcc31"); // 判断 Agent 表 中 是否存在符合条件的数据
bool res2 = await Conn
.Queryer<Agent>()
.Where(it => it.Id == pk2)
.IsExistAsync();
以 MySQL 为例,生成 SQL 如下:
select count(*)
from `Agent`
where `Id`=?Id_1;
四.API 多表连接-完整 方法 举例
1.多表连接-完整, 判断是否存在方法
var pk2 = Guid.Parse("002c1ca9-f2df-453a-87e0-0165443dcc31"); // 判断 Agent表 与 AgentInventoryRecord表 连接下, 是否存在符合条件数据
bool res4 = await Conn
.Queryer(out Agent agent4, out AgentInventoryRecord record4)
.From(() => agent4)
.InnerJoin(() => record4)
.On(() => agent4.Id == record4.AgentId)
.Where(() => agent4.Id == pk2)
.IsExistAsync();
以 MySQL 为例,生成 SQL 如下:
select count(*)
from `Agent` as agent4
inner join `AgentInventoryRecord` as record4
on agent4.`Id`=record4.`AgentId`
where agent4.`Id`=?Id_4;
蒙
2019-01-02 19:25 周三
2019-02-08 14:48 周五
2019-04-12 23:40 周五