工作单元在aspnetboilerplate应用程序服务中无法正常工作

时间:2019-06-13 09:16:38

标签: entity-framework transactions entity-framework-core aspnetboilerplate

在aspnetboilerplate上工作,在app-service中具有以下类型的代码,如果发生错误,则删除后如果不执行已经从数据库中删除的unitOfWork.Complete()数据,则无法正常工作工作单元。

 using (var unitOfWork = _unitOfWorkManager.Begin())
            {
                //delete all items in db....
                var response = _grouppermissionRepository.HardDelete(p => p.GroupId == groupId);

                foreach (var item in pageGroupPermissions)
                {
                    if (item.IsChecked == true)
                    {
                        var grouppermissionObj = new Entities.Setup.GroupPermission()
                        {
                            CompanyId = null,
                            GroupId = item.GroupId,
                            IsActive = true,
                            IsDefault = true,
                            IsDeleted = false,
                            PageId = item.PageId,
                            Permission = item.Permission,
                            TenantId = 2
                        };

                        groupPermissions.Add(grouppermissionObj);
                    }
                }
                _grouppermissionRepository.GetDbContext().AddRange(groupPermissions);

                unitOfWork.Complete();
            }

0 个答案:

没有答案