【发布时间】:2019-07-10 09:36:41
【问题描述】:
我有 2 个项目,都使用相同版本的 AutoMapper。所以这两个项目都需要使用这段代码来配置配置文件
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
//CreateMap goes here
}
}
如你所见,我将从 AutoMapper 继承类 Profile。但是问题发生在另一个项目上。
这个项目的命名空间是Profile.API。那么发生了什么是我收到错误'Profile' is a namespace but is used like a type
这是我的课程AutoMapperProfile的完整代码
using AutoMapper;
namespace Profile.API.Infrastructure.AutoMapper
{
public class AutoMapperProfile : Profile
{
public AutoMapperProfile()
{
//CreateMap goes here
}
}
}
需要建议
【问题讨论】:
-
完全限定基类:
AutoMapperProfile : Fully.Qualified.Profile。 -
不能,仍然错误@ErikPhilips
-
问题已解决,只需将文件夹从“AutoMapper”重命名为另一个名称。然后可以使用
AutoMapperProfile : AutoMapper.Profile
标签: c# .net-core automapper