2

I have two class TenantRestrictSourceEntity, TenantRestrictSource and mapper profile

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

When I map one TenantRestrictSourceEntity to one TenantRestrictSource with Mapper.Map(tenantRestrictSourceEntity, tenantRestrictSource). Everything works fine. Tenant property was ignored correctly.

But when I try to map a list TenantRestrictSourceEntity to a list TenantRestrictSource with Mapper.Map(tenantRestrictSourceEntities, tenantRestrictSources) Tenant property is always null.

How can I ignore that property when mapping a list object?

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69
Hung Quach
  • 2,079
  • 2
  • 17
  • 28

0 Answers0