1.1K Star 4.2K Fork 1.5K

GVPdotNET China / OpenAuth.Net

 / 详情

事务中使用异步方式后报错

Done
owner
Opened this issue  
2022-11-26 21:50

输入图片说明

输入图片说明

Comments (1)

李玉宝 created任务
李玉宝 changed issue state from 待办的 to 进行中
李玉宝 set assignee to 李玉宝
李玉宝 added
 
bug
label
Expand operation logs

新方法ExecuteWithTransactionAsync使用方式如下:


        public async Task Test()
        {
            await UnitWork.ExecuteWithTransactionAsync(async () =>
            {
                var account = await TestAdd();
                UnitWork.Add(new SysLog()
                {
                    Content = $"新增了用户{account}",
                    Id = account
                });
                UnitWork.Save();
            });
        }
        
        private async Task<string> TestAdd()
        {
            var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");

            var user = new User
            {
                Account = account,
                Name = account
            };
            await Repository.AddAsync(user);
            return account;
        }
李玉宝 changed issue state from 进行中 to 已完成

Sign in to comment

Status
Assignees
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(1)
362401 yubaolee 1578921538
C#
1
https://gitee.com/dotnetchina/OpenAuth.Net.git
git@gitee.com:dotnetchina/OpenAuth.Net.git
dotnetchina
OpenAuth.Net
OpenAuth.Net

Search