abp(net core)+easyui+efcore实现仓储管理系统——ABP升级7.3下(五十九)
Abp(net core)+easyui+efcore实现仓储管理系统目录
承接上文abp(net core)+easyui+efcore实现仓储管理系统——ABP升级7.3上(五十八)继续来讲讲升级过程中碰到的问题。
第四个问题
升级过程中碰到的第四个问题:Value cannot be null. (Parameter 'unitOfWork')
在Visual Studio 2022 的解决方案资源管理器中,找到ABP.TPLMS.Application项目中的Modules文件夹中的ModuleAppService.cs文件,是这个文件中的GetAll()方法报了这个错误。错误信息如下图。具体代码如下。
public List<Module> GetAll()
{ var modules= _moduleRepository.GetAllListAsync();
return modules.Result;
}

在“用户未处理的异常”信息弹出框中,使用鼠标左键点击“查看详细信息”,会弹出“快速监视”弹出框,如下图。我们看到具体的错误信息是Value cannot be null. (Parameter 'unitOfWork')

经过一番的资料搜集,最后在官网的文档(https://aspnetboilerplate.com/Pages/Documents/Unit-Of-Work#non-transactional-unit-of-work)中找到以下这段,说明了这个错误。解决方案也在文档中。
By its nature, a unit of work is transactional. ASP.NET Boilerplate starts, commits or rolls back an explicit database-level transaction. In some special cases, the transaction may cause problems since it may lock some rows or tables in the database. In these situations, you may want to disable the database-level transaction. The UnitOfWork attribute can get a boolean value in its constructor to work as non-transactional. Example usage:

在Visual Studio 2022 的解决方案资源管理器中,找到ABP.TPLMS.Application项目中的Modules文件夹中的ModuleAppService.cs文件,是这个文件中的GetAll()上方添加禁用UnitOfWork事务的特性。具体代码如下:
[UnitOfWork(isTransactional:false)]
public List<Module> GetAll()
{ var modules = _moduleRepository.GetAllListAsync();
return modules.Result;
}
第五个问题
升级过程中碰到的第五个问题:Can't create component 'ABP.TPLMS.Modules.ModuleAppService' as it has dependencies to be satisfied.Service 'AutoMapper.IMapper' which was not registered.
在Visual Studio 2022 的解决方案资源管理器中,按F5运行,Visual Studio 2022又抛出一个新的错误。这个问题实际上是之前的第三个问题的后续,由于第三个问题没有解决好,才引发了这个问题。错误信息如下图。

public class ModuleAppService : ApplicationService, IModuleAppService
{ private readonly IRepository<Module> _moduleRepository;
AutoMapper.IMapper m_map; public ModuleAppService(IRepository<Module> moduleRepository, IMapper map) {
_moduleRepository = moduleRepository;
m_map = map;
}
}
在“用户未处理的异常”信息弹出框中,使用鼠标左键点击“查看详细信息”,会弹出“快速监视”弹出框,如下图。我们看到具体的错误信息是:

具体的错误信息如下:
Can't create component 'ABP.TPLMS.Modules.ModuleAppService' as it has dependencies to be satisfied.
'ABP.TPLMS.Modules.ModuleAppService' is waiting for the following dependencies:
- Service 'AutoMapper.IMapper' which was not registered.
这个错误,说明我们的注入方式错误,AutoMapper没有注册,但是我们这是ABP,不是单独使用AutoMapper,需要单独注册,有人会去从nuget上安装automapper包,然后进行注册。我认为,应该有一种方式能解决这个问题。我找到的方法是使用ObjectMapper.Map方法,具体代码如下。
using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.Domain.Repositories;
using Abp.Domain.Uow;
using ABP.TPLMS.Entitys;
using ABP.TPLMS.Modules.Dto;
using AutoMapper;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
using System.Reflection.PortableExecutable;
using System.Text;
using System.Threading.Tasks; namespace ABP.TPLMS.Modules
{
public class ModuleAppService : ApplicationService, IModuleAppService
{
private readonly IRepository<Module> _moduleRepository;
// AutoMapper.IMapper m_map; public ModuleAppService(IRepository<Module> moduleRepository)
{
_moduleRepository = moduleRepository;
// m_map =map;
}
public Task CreateAsync(CreateUpdateModuleDto input)
{
var module= ObjectMapper.Map<Module>(input);
// var module = Mapper.Map<Module>(input); return _moduleRepository.InsertAsync(module);
}
public Task UpdateAsync(CreateUpdateModuleDto input)
{
Logger.Info("更新操作-日记记录 - 模块类型的名称 为:" + input.DisplayName);
var module = ObjectMapper.Map<Module>(input);
// var module = m_map.Map<Module>(input);
return _moduleRepository.UpdateAsync(module);
}
public async Task<ListResultDto<ModuleDto>> GetAllAsync()
{
var modules = await _moduleRepository.GetAllListAsync();
return new ListResultDto<ModuleDto>(ObjectMapper.Map<List<ModuleDto>>(modules)); } [UnitOfWork(isTransactional:false)]
public List<Module> GetAll()
{
var modules = _moduleRepository.GetAllListAsync();
return modules.Result; } public async Task DeleteAsync(int Id)
{
await _moduleRepository.DeleteAsync(Id);
} public void Delete(int Id)
{
_moduleRepository.Delete(Id);
} }
}
在修改完了代码之后,在Visual Studio 2022中按F5运行,终于看到了登录界面,在登录界面中的用户名中输入admin,在密码输入框中输入123qwe这个默认密码。浏览器自动跳转到了首页面。如下图。

第六个问题:
升级过程中碰到的第六个问题:Missing type map configuration or unsupported mapping.
在浏览器的左边的菜单栏中有一个Business菜单,使用鼠标左键点击,展开。在展开的菜单栏,使用鼠标左键点击“模块管理”,Visual Studio 2022将会弹出一个错误。如下图。

在“用户未处理的异常”信息弹出框中,使用鼠标左键点击“查看详细信息”,会弹出“快速监视”弹出框,如下图。我们看到具体的错误信息是:
Missing type map configuration or unsupported mapping.
Mapping types:
Object -> CreateUpdateModuleDto
System.Object -> ABP.TPLMS.Modules.Dto.CreateUpdateModuleDto

这个错误是由于我们没有定义autoMapper需要的配置信息。
1. 在Visual Studio 2022的“解决方案资源管理器”中,左键单击“ABP.TPLMS.Application”项目,进行展开,找到“Modules\Dto”文件夹。
2.右键单击“Dto”文件夹,然后选择“添加” > “类”。 将类命名为 ModuleMapProfile,然后选择“添加”。代码如下。
using ABP.TPLMS.Authorization.Users;
using ABP.TPLMS.Entitys;
using ABP.TPLMS.Users.Dto;
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ABP.TPLMS.Modules.Dto
{
public class ModuleMapProfile:Profile
{
public ModuleMapProfile()
{ CreateMap<ModuleDto, Module>();
CreateMap<ModuleDto, CreateUpdateModuleDto>();
CreateMap<CreateUpdateModuleDto, Module>();
}
}
}
3.在添加完ModuleMapProfile类的代码之后,在Visual Studio 2022中按F5运行,在登录界面中的用户名中输入admin,在密码输入框中输入123qwe这个默认密码。浏览器自动跳转到了首页面。
4.在浏览器的左边的菜单栏中有一个Business菜单,使用鼠标左键点击,展开。在展开的菜单栏,使用鼠标左键点击“模块管理”,然后我们看到了模块管理的页面,如下图。 
至此项目中的一些问题解决了,ABP.TPLMS能初步运行了,项目也初步升级到了ABP 7.3,不过,这只是第一步,在后续测试中,应该还会有一些问题。
abp(net core)+easyui+efcore实现仓储管理系统——ABP升级7.3下(五十九)的更多相关文章
- abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之一(二十七)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- 2019年7月16日 abp(net core)+easyui+efcore实现仓储管理系统——多语言(十)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十二)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十三)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十四)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+ ...
- abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十五)
core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+e ...
- abp(net core)+easyui+efcore实现仓储管理系统——菜单 (十六)
系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二) ...
- abp(net core)+easyui+efcore实现仓储管理系统——菜单-下(十七)
实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案 ...
随机推荐
- scala中变量常量字符串使用
1.注释 scala注释使用与java完全一样: 2.变量和常量 (1).常量:在程序执行中,其值不会改变的变量: 基本语法:var 变量名称:变量类型 = 变量初始值 var num1:Int = ...
- 关于Python文件读取时,默认把\r\n换成\n
Python在非二进制形式读取文件时,自动把\r\n换成\n.(window下换行是\r\n) 建立一个test1.txt文件, aaaa bbbb 1.在utf8方式下读取 读取四个字符 1 f=o ...
- element ui 点击选中表头并改变表头样式
前言: header-cell-style 表头单元格的 style 的回调方法,也可以使用一个固定的 Object 为所有表头单元格设置一样的 Style. Function({row, colum ...
- Python测试——安装篇总结
测试用到的工具自己知道的有: 写脚本类:sublime ,PyCharm,Eclipse+PyDev,目前我知道的只有这么多,大家知道的肯定还有很多,欢迎留言哈 录制脚本类:火狐自带的seleniu ...
- 第12组 Beta冲刺 (3/5)
1.1基本情况 ·队名:美少女战士 ·组长博客:https://www.cnblogs.com/yaningscnblogs/p/14016611.html ·作业博客:https://edu.cnb ...
- 狂神学习笔记domo6
1.新特性,1000000000可以写成10_0000_0000便于阅读 2.强制类型转换 先强制类型转换再赋值才能正确的结果 public class domo06 { public static ...
- java的两种线程
java中的两种线程 守护线程与用户线程 守护线程:就是服务于用户线程的线程,例如垃圾回收的线程及时最典型的守护线程.不需要上层逻辑的介入 用户线程:就是程序自己创建的线程 守护线程; 守护线 ...
- mysql安装调试
mysql安装 1.下载mysql的压缩包 tar -xvzf mysql-5.6.38-linux-glibc2.12-i686.tar.gz2.安装之后密码是随机的,所以我们需要重新修改密码: [ ...
- Postman设置Cookie参数为全局变量-环境变量设置IP参数
前提:在遇到多接口测试时,容易出现限制登录的情况 可以使用两种情况: 1.在调用其他接口前,先调用登录接口:这个方法在一般情况下可以,但是对于有些环境,比如像小程序登录时token(或cookie)是 ...
- A better jump —— 优化游戏中的跳跃
之前一提起角色的跳跃,想当然的想法就是:给角色一个向上的初速,然后由Unity的物理系统接管就好了嘛,这样忽略空气摩擦的影响,根据重力加速度,角色向上跳到最高点的时间和由最高点落下的时间相等,不是很合 ...