public async Task Update_Shortcut() { xx = string.Empty; var pk1 = Guid.Parse("8f2cbb64-8356-4482-88ee-016558c05b2d"); // 修改一条数据: AlipayPaymentRecord var res1 = await Conn2.UpdateAsync <AlipayPaymentRecord>(it => it.Id == pk1, // where 条件: it=>it.Id==pk1 new { Description = "new desc", // 修改 AlipayPaymentRecord 字段 Description 的值为: "new desc" PaymentUrl = "new url" // 修改 AlipayPaymentRecord 字段 PaymentUrl 的值为: "new url" }); Assert.IsTrue(res1 == 1); // 查询一条数据: AlipayPaymentRecord var res11 = await Conn2.QueryOneAsync <AlipayPaymentRecord>(it => it.Id == pk1); Assert.IsTrue(res11.Description == "new desc"); /****************************************************************************************/ xx = string.Empty; }
public async Task QueryVM_SQL() { xx = string.Empty; var totalSql = @" select count(*) from ( select agent9.[Name] as XXXX, agent9.[PathId] as YYYY from [agent] as agent9 inner join [agentinventoryrecord] as record9 on agent9.[Id]=record9.[AgentId] where agent9.[AgentLevel]=@AgentLevel ) temp; "; var dataSql = @" select agent9.[Name] as XXXX, agent9.[PathId] as YYYY from [agent] as agent9 inner join [agentinventoryrecord] as record9 on agent9.[Id]=record9.[AgentId] where agent9.[AgentLevel]=@AgentLevel order by agent9.[Id] desc offset 0 rows fetch next 10 rows only; "; var paras = new List <XParam> { new XParam { ParamName = "AgentLevel", ParamValue = AgentLevel.DistiAgent, ParamType = ParamTypeEnum.Int_MySQL_SqlServer } }; var paging = new PagingResult <AgentVM>(); paging.PageIndex = 1; paging.PageSize = 10; paging.TotalCount = await Conn2.QueryOneAsync <int>(totalSql, paras); paging.Data = await Conn2.QueryListAsync <AgentVM>(dataSql, paras); Assert.IsTrue(paging.Data.Count == 10); xx = string.Empty; }
public async Task CreateAsync_SQL() { xx = string.Empty; var m = new AlipayPaymentRecord { Id = Guid.Parse("DDED9817-A73B-490F-9289-016558ECB41C"), CreatedOn = DateTime.Parse("2018-08-20 13:48:03.320317"), PaymentRecordId = Guid.Parse("99b4afd3-9442-4556-a4bf-01655797af73"), OrderId = Guid.Parse("c18aa87e-3367-4813-952d-01655797af41"), TotalAmount = 293.000000000000000000000000000000M, Description = null, PaymentSN = null, PayedOn = null, CanceledOn = null, PaymentUrl = "https://openapi.alipay.com/gateway.do?charset=UTF-8" }; // 删除一条数据: AlipayPaymentRecord await Conn2.DeleteAsync <AlipayPaymentRecord>(it => it.Id == m.Id); var sql = @" insert into [alipaypaymentrecord] ([Id],[CreatedOn],[PaymentRecordId],[OrderId],[TotalAmount],[Description],[PaymentSN],[PayedOn],[CanceledOn],[PaymentUrl]) values (@Id,@CreatedOn,@PaymentRecordId,@OrderId,@TotalAmount,@Description,@PaymentSN,@PayedOn,@CanceledOn,@PaymentUrl); "; var paras = new List <XParam> { new XParam { ParamName = "Id", ParamValue = m.Id }, new XParam { ParamName = "CreatedOn", ParamValue = m.CreatedOn }, new XParam { ParamName = "PaymentRecordId", ParamValue = m.PaymentRecordId }, new XParam { ParamName = "OrderId", ParamValue = m.OrderId }, new XParam { ParamName = "TotalAmount", ParamValue = m.TotalAmount }, new XParam { ParamName = "Description", ParamValue = m.Description }, new XParam { ParamName = "PaymentSN", ParamValue = m.PaymentSN }, new XParam { ParamName = "PayedOn", ParamValue = m.PayedOn }, new XParam { ParamName = "CanceledOn", ParamValue = m.CanceledOn }, new XParam { ParamName = "PaymentUrl", ParamValue = m.PaymentUrl } }; // 新增一条数据: AlipayPaymentRecord var res1 = await Conn2.CreateAsync(sql, paras); Assert.IsTrue(res1 == 1); var res11 = await Conn2.QueryOneAsync <AlipayPaymentRecord>(it => it.Id == m.Id); Assert.IsNotNull(res11); xx = string.Empty; }