Open Closed

Not Getting Custom Mapping #1212


User avatar
0
RonaldR created
  • ABP Framework version: v4.2

  • UI type: MVC

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): no

  • Exception message and stack trace:

  • Steps to reproduce the issue:

  • I have a data class and a model class. i sem calling createMap in the Profile class to set up my mapping. the problem i am having is there is a foreign key to another table and a member of the type for that table. when the data gets to the fron end the site data object is not in there. i added a SiteName field, which is the data i need on the UI. i altered the CreateMap by adding a ForMembet call. still not getting the name in the mapped data. here are the two modeks and the mapping:

public class SubnetDataModel : AuditedAggregateRoot, IMultiTenant
{
    public Guid? TenantId { get; set; }
    public string Network { get; set; }
    public string MaskBit { get; set; }
    public string StartRange { get; set; }
    public string EndRange { get; set; }
    //public string Category { get; set; }
    public SiteDataModel SiteData { get; set; }
    [ForeignKey("SiteData")]
    public Guid? SiteId { get;  set; }
}

 public class SubnetModel : AuditedEntityDto
{
    public string Network { get; set; }
    public string MaskBit { get; set; }
    public string StartRange { get; set; }
    public string EndRange { get; set; }
    //public SiteModel SiteData { get; set; }
    public Guid? SiteId { get; set; }
    public string SiteName { get; set; }
}

CreateMap().ForMember(x => x.SiteName, y => y.MapFrom(src => src.SiteData.Name));

1 Answer(s)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 11, 2025, 10:10