Mit dem folgenden Code, warum bekomme ich während der Mapping-Phase immer eine Ausnahme? Sind die 2 DTOs wirklich so unterschiedlich? Hier ist die Codezeile vom Symbolserver pdb, die die Ausnahme auslöst.Warum wird diese AutoMapper-Konfiguration nicht richtig zugeordnet?
throw new AutoMapperMappingException(context, "Missing type map configuration or unsupported mapping.");
Was wirklich bringe ich bin, dass @jbogard einen Killer-Job von Ausnahmebehandlung und Instrumentierung in Bezug getan AutoMapper hat, gibt es viele Kontextdaten für sowohl die Quell- und Zielobjekte und der Zustand des Mapper wenn eine Ausnahme ausgelöst wird ..und ich kann es immer noch nicht herausfinden.
void Main()
{
var config = new MapperConfiguration(cfg =>
{
cfg.ShouldMapProperty = p => p.GetMethod.IsPublic || p.GetMethod.IsVirtual;
cfg.CreateMap<Customer, Customer2>()
.ReverseMap();
});
config.AssertConfigurationIsValid();
Customer request = new Customer
{
FirstName = "Hello", LastName = "World"
};
request.FullName = request.FirstName + " " + request.LastName;
Customer2 entity = Mapper.Map<Customer, Customer2>(request);
Console.WriteLine("finished");
}
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName { get; set; }
}
[Serializable()]
public partial class Customer2
{
private string _firstName;
private string _lastName;
private string _fullName;
public virtual string FirstName
{
get
{
return this._firstName;
}
set
{
this._firstName = value;
}
}
public virtual string LastName
{
get
{
return this._lastName;
}
set
{
this._lastName = value;
}
}
public virtual string FullName
{
get
{
return this._fullName;
}
set
{
this._fullName = value;
}
}
}
Danke, Stephen
Was sind die Details der Ausnahme wird ausgelöst? – lzcd
'Kunde2' ist mit' partiell' gekennzeichnet, wo ist der Rest der Klasse? –