0

I am attempting to map these complex types using ValueInjecter but the mapped object all of the properties are null.

DTO

public class HardwareSettingsDto
{
    public HardwareSettingsDto()
    {
        EmailAlertSettings = new EmailAlertSettingsDto();
        CpuMonitoring = new CpuMonitoringDto();
        NetworkMonitoring = new NetworkMonitoringDto();
    }

    // I wont include the below classes but they contain property types of int, string, bool etc.
    public CpuMonitoringDto CpuMonitoring { get; set; }
    public NetworkMonitoringDto NetworkMonitoring { get; set; }
    public List<DriveSettingsDto> Drives { get; set; }
    public EmailAlertSettingsDto EmailAlertSettings { get; set; }
}

Entity

public class HardwareSettings
{
    public HardwareSettings()
    {
        EmailAlertSettings = new EmailAlertSettings();
        CpuMonitoring = new CpuMonitoring();
        NetworkMonitoring = new NetworkMonitoring();
    }

    public CpuMonitoring CpuMonitoring { get; set; }
    public NetworkMonitoring NetworkMonitoring { get; set; }
    public List<DriveSettings> Drives { get; set; }
    public EmailAlertSettings EmailAlertSettings { get; set; }
}

I cannot seem to map them back and forth DTO -> Entity and then Entity -> DTO as everything is null.

Jamie Rees
  • 7,973
  • 2
  • 45
  • 83
  • please read this carefully https://github.com/omuleanu/ValueInjecter/blob/master/README.md – Omu Jan 28 '16 at 18:46
  • @Omu the `Mapper.AddMap` Where should I create the Map? At the beginning of the application lifecycle? Does the `AddMap` stay throughout the application lifecycle OR do I just create the map when I want to use it? – Jamie Rees Jan 28 '16 at 21:16
  • `Mapper` maps are saved in a static field, you can look at prodinner demo for asp.net mvc sample – Omu Jan 29 '16 at 19:11

0 Answers0