public async Task Concat_Multi_ST()
        {
            xx = string.Empty;

            var userId    = "08d6036b-0a7e-b07d-b9bd-af03841b3baa";
            var firstName = "伏";

            var where = Conn2.Queryer <Agent>().WhereSegment;

            // 条件1
            if (!userId.IsNullStr())
            {
                where = where.And(it => it.UserId == Guid.Parse(userId));
            }
            // 条件2
            if (!firstName.IsNullStr())
            {
                where = where.And(it => it.Name.StartsWith(firstName));
            }

            var res1 = await where.QueryListAsync();

            Assert.IsTrue(res1.Count == 1);



            xx = string.Empty;
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        public async Task Mock_DeleteAll_ST()
        {
            xx = string.Empty;

            var res1 = await Conn2.DeleteAsync <AddressInfo>(it => true);

            Assert.IsTrue(res1 == 7);



            xx = string.Empty;
        }
Beispiel #4
0
        public async Task SqlAction_Distinct_Count_SpecialColumn_ST()
        {
            xx = string.Empty;

            var res1 = await Conn2
                       .Queryer <Agent>()
                       .Distinct()
                       .CountAsync(it => it.AgentLevel);

            Assert.AreEqual(3, res1);

            xx = string.Empty;
        }
Beispiel #5
0
//FOLD00

    public void    Close()
    {
        if (Conn1 != null)
        {
            Conn1.Close();
            Conn1 = null;
        }
        if (Conn2 != null)
        {
            Conn2.Close();
            Conn2 = null;
        }
    }
        public async Task Concat_None_ST()
        {
            xx = string.Empty;

            var where = Conn2.Queryer <Agent>().WhereSegment;

            var res1 = await where.TopAsync(1);

            Assert.IsNotNull(res1);



            xx = string.Empty;
        }
Beispiel #7
0
        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;
        }
Beispiel #8
0
        public async Task Sum_Nullable_ST()
        {
            xx = string.Empty;

            var res1 = await Conn2
                       .Queryer <AgentInventoryRecord>()
                       .Where(it => it.Id != Guid.Parse("df2b788e-6b1a-4a74-ac1d-016551f76dc9"))
                       .SumAsync(it => it.TotalSaleCount);

            Assert.IsTrue(res1 == 589);



            xx = string.Empty;
        }
Beispiel #9
0
        public async Task Create_Batch_Shortcut()
        {
            var list = await new CreateData().PreCreateBatchV2(Conn2);

            xx = string.Empty;

            var res1 = await Conn2.OpenDebug().CreateBatchAsync(list);

            Assert.IsTrue(res1 == 10);



            /********************************************************************************************************************************/

            xx = string.Empty;
        }
Beispiel #10
0
        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;
        }