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.

Omnia9
  • 1,563
  • 4
  • 14
  • 39
  • Does this answer your question? [Automapper expression must resolve to top-level member](https://stackoverflow.com/questions/11633021/automapper-expression-must-resolve-to-top-level-member) – aquaman May 08 '23 at 15:58

0 Answers0