我正在尝试使用ASP.NET Boilerplate(.NET Core v3)创建CRUD操作。
当我测试Create
操作时,尽管Get
和GetAll
正常工作(使用Swagger),但它返回“ 500 Internal Server Error”。
using System;
using System.Collections.Generic;
using System.Text;
using BoilerplateTemplate.Entities;
using Abp.Domain.Repositories;
using BoilerplateTemplate.Authorization;
using Abp.Authorization;
namespace BoilerplateTemplate.Products
{
[AbpAuthorize(PermissionNames.Pages_Products)]
public class ProductsAppService : AsyncCrudAppService<Product, ProductDto, int, PagedAndSortedResultRequestDto, ProductDto>
{
public ProductsAppService(IRepository<Product, int> repository) : base(repository)
{
}
}
}
using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using BoilerplateTemplate.Entities;
using System;
using System.Collections.Generic;
using System.Text;
namespace BoilerplateTemplate.Products.DTOs
{
[AutoMapFrom(typeof(Product))]
public class ProductDto:EntityDto<int>
{
public string Name { get; set; }
public int Quantity { get; set; }
}
}
using Abp.Domain.Entities;
using System;
using System.Collections.Generic;
using System.Text;
namespace BoilerplateTemplate.Entities
{
public class Product : Entity<int>
{
public string Name { get; set; }
public int Quantity { get; set; }
}
}
我在Logs.txt文件中找到的内容与“映射”有关:
映射类型: ProductDto->产品 BoilerplateTemplate.Products.DTOs.ProductDto-> BoilerplateTemplate.Entities.Product AutoMapper.AutoMapperMappingException:缺少类型映射配置或不支持的映射。