Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error in AutoMapper
Message
 
 
À
17/08/2014 03:48:26
Information générale
Forum:
ASP.NET
Catégorie:
Programmation orienté objet
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01605838
Message ID:
01605977
Vues:
40
>>>I've never used AutoMapper but you seem to be mapping from a small object to a larger one with additional properties - do you have it the wrong way around ?
>>>Or do you have some rule in the map which tells it how to populate ItemType ?
>>
>>In order to resolve that problem I had to add ItemType to the model as well.
>
>Adding a member to the source to get round the problem doesn't sound right. Would adding the
.ForMember(dest => dest.ItemType, opt => opt.Ignore());
to your CreateMap method work instead ?
>
> > I don't know why all other properties were successfully ignored in run-time and this one caused troubles.
>
>Don't know why either. If you try 'Mapper.AssertConfigurationIsValid();' I think you will find that it will complain about all unmapped members in the destination class.
>
>Can you post the two class definition :?
>
>Update: I see in the original exception a 'ItemType.ItemType' and there is an ItemType property in C# RepeaterItem. Maybe AutoMapper is confused by this. Do you get the exception if you change the name ?

What do you mean by changing the name? The Model class is auto-generated, so I can not really change it. I may try your idea of ignore although I already made that change and by-passed the error by adding the property to the view model (and I also changed repository to return this field among the others).

BTW, AssertConfigurationValid complained about many properties (all extra properties in many classes), but not this one (the ItemType was not mentioned).
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform