Question

I just started using ValueInjecter for my Entity Mappings(DTO <-> Entity). Heres my DTO :

public class IncidentDTO
{
    int ID { get; set; }
    string Name { get; set; }
    AgencyDTO agencyDTO { get; set; }
}

public class AgencyDTO
{
    int ID { get; set; }
    string Name { get; set; }
    List<IncidentTypeDTO> incidentTypeDTOList { get; set; }
}

public class IncidentTypeDTO
{
    int ID { get; set; }
    string TypeName { get; set; }
}

Heres my NHibernate Proxy classes :

 public class Incident
{
    int ID { get; set; }
    string Name { get; set; }
    Agency agency { get; set; }
}

public class Agency
{
    int ID { get; set; }
    string Name { get; set; }
}

public class IncidentType
{
    int ID { get; set; }
    string TypeName { get; set; }
}

public class AgencyIncidentType
{
    int ID { get; set; }
    Agency agency { get; set; }
    IncidentType incidentType { get; set; }
}

Now, I need to query IncidentDTO from Repository. Repository query Incident & AgencyIncidentType tables from database and map Incident -> IncidentDTO using ValueInjecter and return IncidentDTO.

What is the best possible way to do the above mapping using ValueInjecter??

Thanks, Prateek

Était-ce utile?

La solution

If you want to map Incident to IncidentDTO while retaining and mapping the Agency object in the agency property (to an AgencyDTO) of an Incident instance I'd suggest renaming the agencyDTO property to agency in your IncidentDTO and then use a tweak to the CloneInjection sample from the Value Injector documentation as described here: omu.valueinjecter deep clone unlike types

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top