小编PJL*_*PJL的帖子

具有下划线/PascalCase 属性的 Automapper 命名约定

我想用 Automapper 映射 2 个类:

namespace AutoMapperApp
{
    public class Class1
    {
        public string Test { get; set; }
        public string property_name { get; set; }
    }
}

namespace AutoMapperApp
{
    public class Class2
    {
        public string Test { get; set; }
        public string PropertyName { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的自动映射器配置:

using AutoMapper;

namespace AutoMapperApp
{
    public static class AutoMapperConfig
    {
        public static MapperConfiguration MapperConfiguration;

        public static void RegisterMappings()
        {
            MapperConfiguration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap<Class1, Class2>();
                cfg.SourceMemberNamingConvention …
Run Code Online (Sandbox Code Playgroud)

c# automapper

4
推荐指数
1
解决办法
8355
查看次数

标签 统计

automapper ×1

c# ×1