我有两个TenantRestrictSourceEntity
,TenantRestrictSource
和映射器个人资料
CreateMap<TenantRestrictSourceEntity, TenantRestrictSource>()
.ForMember(dest => dest.Tenant, opt => opt.Ignore());
public class TenantRestrictSourceEntity
{
public string SourceType { get; set; }
public bool? Enable { get; set; }
public int TenantId { get; set; }
}
public sealed class TenantRestrictSource
{
public int Id { get; set; }
public string SourceType { get; set; }
public bool Enable { get; set; }
public int TenantId { get; set; }
public Tenant Tenant { get; set; }
}
当我使用TenantRestrictSourceEntity
将一个TenantRestrictSource
映射到一个Mapper.Map(tenantRestrictSourceEntity, tenantRestrictSource)
时。一切正常。租户属性被正确忽略。
但是当我尝试将列表TenantRestrictSourceEntity
映射到具有TenantRestrictSource
的列表Mapper.Map(tenantRestrictSourceEntities, tenantRestrictSources)
时,承租人属性始终为null
。
映射列表对象时如何忽略该属性?