我正在尝试将一个简单的模型映射到一个实体,但得到一个我没想到的未映射项目列表,它在 AutomapperCfg 的验证行失败:
SaveImportRunDetailsModel -> ImportRunDetailEntity(目标成员列表) FCSD.Models.SaveImportRunDetailsModel -> LLBLGEN.EntityClasses.ImportRunDetailEntity(目标成员列表)
未映射的属性:
Id
ConcurrencyPredicateFactoryToUse
AuthorizerToUse
AuditorToUse
Validator
ActiveContext
IsNew
Fields
IsDirty
这些看起来像系统生成的项目,有没有办法消除它们?
AutomapperCfg.cs 是
using AutoMapper;
using FCSD.Models;
using LLBLGEN.EntityClasses;
namespace FCSD.Automapper
{
public class AutomapperCfg : IAutomapperCfg
{
public void Configure()
{
Mapper.Initialize(cfg =>
{
cfg.CreateMap<CategoryEntity, Category>(MemberList.Destination);
cfg.CreateMap<EnglishPartInfoEntity, EnglishPartModel>(MemberList.Destination);
cfg.CreateMap<ImageEntity, Image>(MemberList.Destination);
cfg.CreateMap<ImportRunDetailEntity, ImportRunDetailModel>(MemberList.Destination);
cfg.CreateMap<ModelExportBaseEntity, Model>(MemberList.Destination).ReverseMap();
cfg.CreateMap<PartEntity, Part>(MemberList.Destination);
cfg.CreateMap<SaveImportRunDetailsModel, ImportRunDetailEntity>(MemberList.Destination);
});
Mapper.AssertConfigurationIsValid();
}
}
}
SaveImportRunDetailsModel 是
using System;
namespace FCSD.Models
{
public class SaveImportRunDetailsModel
{
public string PHCreationDate { get; set; }
public DateTime RunTimestamp { get; set; }
}
}
最后,ImportRunDetailEntity 有点长(超过 400 行)并且是从 LLBLGen Pro 自动生成的 c#。