1

I use Automapper all the time, and for some reason the issue is escaping me. Below is an example of the code I'm using (names have been changed.)

Problem All objects are mapped but the Keys object.

Code I have a flat object coming from a WCF service.

public class FlatDTO
{
public string Key1 {get;set;}
public string Key2 {get;set;}
public string Name {get;set;}
public DateTime Date {get;set;}
}

This is the structure for my Business Object:

public class BaseModel
{
public Datetime Date{get;set;}
}

public class Keys
{
public string Key1 {get;set;}
public string Key2 {get;set;}
}

public class Summary : BaseModel
{
public Keys List {get;set;}
public string Name{get;set;}

public Summary ()
{
List = new Keys();
}
}

Below is my profile for Automapper (the init of the profile is done in the global.aspx page)

internal class MapDTO : Profile
{
protected override void configure()
{
  Mapper.CreateMap<FlatDTO,BaseModel>().IgnoreAllNonExisting();
Mapper.CreateMap<FlatDTO,Role>().IgnoreAllNonExisting();
Mapper.CreateMap<FlatDTO,Summary>().IgnoreAllNonExisting();

}

Help with this 'simple' issue would be great.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.