我有两个类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
.
映射列表对象时如何忽略该属性?