1

我有两个类TenantRestrictSourceEntityTenantRestrictSource映射器配置文件

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; }
}

当我TenantRestrictSourceEntityTenantRestrictSource. Mapper.Map(tenantRestrictSourceEntity, tenantRestrictSource)一切正常。租户属性被正确忽略。

但是,当我尝试将列表映射TenantRestrictSourceEntityTenantRestrictSource具有Mapper.Map(tenantRestrictSourceEntities, tenantRestrictSources)租户属性的列表时,总是null.

映射列表对象时如何忽略该属性?

4

0 回答 0