Пример #1
0
        public async Task Update_SetField_NotAllowedNull_Shortcut()
        {
            xx = string.Empty;

            var agent = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == Guid.Parse("040afaad-ae07-42fc-9dd0-0165443c847d"));

            agent.PathId = null;

            try
            {
                var res1 = await MyDAL_TestDB.UpdateAsync <Agent>(it => it.Id == agent.Id, new
                {
                    agent.PathId
                });
            }
            catch (Exception ex)
            {
                var errStr = "【ERR-054】 -- [[NotAllowedNull -- 字段:[[PathId]]的值不能设为 Null !!!]] ,请 EMail: --> [email protected] <--";
                Assert.Equal(errStr, ex.Message, true);
            }

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

            xx = string.Empty;
        }
Пример #2
0
        public async Task Update_SetField_AllowedNull_Shortcut()
        {
            xx = string.Empty;

            var agent = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == Guid.Parse("040afaad-ae07-42fc-9dd0-0165443c847d"));

            agent.PathId = null;

            var res1 = await MyDAL_TestDB.UpdateAsync <Agent>(it => it.Id == agent.Id, new
            {
                agent.PathId
            });

            Assert.True(res1 == 1);



            var res11 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == agent.Id);

            Assert.Null(res11.PathId);

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

            xx = string.Empty;
        }
Пример #3
0
        public async Task Update_Shortcut_02()
        {
            xx = string.Empty;

            var pk1 = Guid.Parse("8f2cbb64-8356-4482-88ee-016558c05b2d");

            var model = new AlipayPaymentRecord();

            model.Description = "new desc"; // 修改 AlipayPaymentRecord 字段 Description 的值为: "new desc"
            model.PaymentUrl  = "new url";  //  修改 AlipayPaymentRecord 字段 PaymentUrl 的值为: "new url"

            // 修改一条数据: AlipayPaymentRecord
            var res1 = await MyDAL_TestDB.UpdateAsync <AlipayPaymentRecord>(it => it.Id == pk1,  // where 条件: it=>it.Id==pk1 , 可输入任意条件的表达式
                                                                            new
            {
                model.Description,  // 修改 AlipayPaymentRecord 字段 Description 的值
                model.PaymentUrl    //  修改 AlipayPaymentRecord 字段 PaymentUrl 的值
            });

            Assert.True(res1 == 1);



            // 查询一条数据: AlipayPaymentRecord
            var res11 = await MyDAL_TestDB.SelectOneAsync <AlipayPaymentRecord>(it => it.Id == pk1);

            Assert.True(res11.Description == "new desc");

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

            xx = string.Empty;
        }
Пример #4
0
        public async Task History_03()
        {
            xx = string.Empty;

            var agent = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == Guid.Parse("040afaad-ae07-42fc-9dd0-0165443c847d"));

            agent.PathId        = "yyyyyyy";
            agent.ActiveOrderId = null;

            var res1 = await MyDAL_TestDB.UpdateAsync <Agent>(it => it.Id == agent.Id, new
            {
                agent.PathId,
                agent.ActiveOrderId
            });



            var res11 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == agent.Id);

            Assert.Equal("yyyyyyy", res11.PathId, true);
            Assert.Null(res11.ActiveOrderId);

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

            xx = string.Empty;
        }
Пример #5
0
 private async Task PreTrim()
 {
     var pk1  = Guid.Parse("b3866d7c-2b51-46ae-85cb-0165c9121e8f");
     var res1 = await MyDAL_TestDB.UpdateAsync <Product>(it => it.Id == pk1, new
     {
         Title = "  演示商品01  "
     });
 }
Пример #6
0
        public async Task History_01()
        {
            xx = string.Empty;

            var pk2  = Guid.Parse("d0a2d3f3-5cfb-4b3b-aeea-016557383999");
            var res2 = await MyDAL_TestDB.UpdateAsync <AlipayPaymentRecord>(it => it.Id == pk2, new
            {
                Description = "xxxxxx"
            });

            Assert.True(res2 == 1);



            var res21 = await MyDAL_TestDB.SelectOneAsync <AlipayPaymentRecord>(it => it.Id == pk2);

            Assert.True(res21.Description == "xxxxxx");

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

            xx = string.Empty;
        }
Пример #7
0
        public async Task Mock_UpdateAll_Shortcut()
        {
            xx = string.Empty;

            var model = new AgentInventoryRecord();

            model.LockedCount = 0;

            var res1 = await MyDAL_TestDB.UpdateAsync <AgentInventoryRecord>(it => true, new
            {
                model.LockedCount
            });

            Assert.True(res1 == 574);



            var res11 = await MyDAL_TestDB.SelectListAsync <AgentInventoryRecord>(it => it.LockedCount != 0);

            Assert.True(res11.Count == 0);

            xx = string.Empty;
        }
Пример #8
0
        private async Task <Agent> Pre02()
        {
            xx = string.Empty;

            // 造数据
            var pk1   = Guid.Parse("014c55c3-b371-433c-abc0-016544491da8");
            var resx1 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == pk1);

            var resx2 = await MyDAL_TestDB.UpdateAsync <Agent>(it => it.Id == resx1.Id, new
            {
                Name = "刘%华"
            });

            var pk3   = Guid.Parse("018a1855-e238-4fb7-82d6-0165442fd654");
            var resx3 = await MyDAL_TestDB.SelectOneAsync <Agent>(it => it.Id == pk3);

            var resx4 = await MyDAL_TestDB.UpdateAsync <Agent>(it => it.Id == resx3.Id, new
            {
                Name = "何_伟"
            });

            return(resx1);
        }