MyDAL - .IsExistAsync() 使用

索引:html

目錄索引ui

一.API 列表spa

  .IsExistAsync()3d

    用於 單表 / 多表鏈接 查詢code

二.API 單表-便捷 方法 舉例htm

  1.單表-便捷, 判斷是否存在方法blog

1             var date = DateTime.Parse("2018-08-20 20:33:21.584925");
2             var id = Guid.Parse("89c9407f-7427-4570-92b7-0165590ac07e");
3 
4             // 判斷 AlipayPaymentRecord 表中是否存在符合條件的數據
5             bool res1 = await Conn.IsExistAsync<AlipayPaymentRecord>(it => it.CreatedOn == date && it.OrderId == id);

    以 MySQL 爲例,生成 SQL 以下, 在返回結果時 IsExistAsync API 中會判斷結果是否 >0 ,返回 true or false :索引

1 select  count(*)
2 from `AlipayPaymentRecord`
3 where ( `CreatedOn`=?CreatedOn_2 &&  `OrderId`=?OrderId_3);

三.API 單表-完整 方法 舉例ip

  1.單表-完整, 判斷是否存在方法get

1             var pk2 = Guid.Parse("002c1ca9-f2df-453a-87e0-0165443dcc31");
2 
3             // 判斷 Agent 表 中 是否存在符合條件的數據
4             bool res2 = await Conn
5                 .Queryer<Agent>()
6                 .Where(it => it.Id == pk2)
7                 .IsExistAsync();

    以 MySQL 爲例,生成 SQL 以下:

1 select  count(*)
2 from `Agent`
3 where  `Id`=?Id_1;

四.API 多表鏈接-完整 方法 舉例

  1.多表鏈接-完整, 判斷是否存在方法

 1             var pk2 = Guid.Parse("002c1ca9-f2df-453a-87e0-0165443dcc31");
 2 
 3             // 判斷 Agent表 與 AgentInventoryRecord表 鏈接下, 是否存在符合條件數據
 4             bool res4 = await Conn
 5                 .Queryer(out Agent agent4, out AgentInventoryRecord record4)
 6                 .From(() => agent4)
 7                     .InnerJoin(() => record4)
 8                         .On(() => agent4.Id == record4.AgentId)
 9                 .Where(() => agent4.Id == pk2)
10                 .IsExistAsync();

    以 MySQL 爲例,生成 SQL 以下:

1 select  count(*)
2 from `Agent` as agent4 
3     inner join `AgentInventoryRecord` as record4
4         on agent4.`Id`=record4.`AgentId`
5 where  agent4.`Id`=?Id_4;

 

 

 

 

 

                                         蒙

                                    2019-01-02 19:25 週三

                                    2019-02-08 14:48 週五

                                    2019-04-12 23:40 週五

相關文章
相關標籤/搜索