Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error in AutoMapper
Message
 
 
À
18/08/2014 03:45:30
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:
01606007
Vues:
46
>>What do you mean by changing the name? The Model class is auto-generated, so I can not really change it.
>

In the AutoMapper config we have defined maps 2 ways. The Model class is in the Models project and all the models are created based on the data and auto-generated and should not be changed. The ViewModels were also initially generated using scaffolding, but I have flexibility to change ViewModel classes.


>Not sure whether you regard the 'Model' as being the source or destination class. If it's the destination class how is it 'auto-generated' ?
>If it's not the destination class then what stops you changing the name ?
>
>> 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).
>
>Having to pull ItemType from the repository when you don't really need it just to avoid the exception smells like a cop-out :-}
>
>>BTW, AssertConfigurationValid complained about many properties (all extra properties in many classes), but not this one (the ItemType was not mentioned).
>
>That's odd. It implies that AutoMapper thinks it can resolve ItemType but, when it comes down to it, can't.
>My guess, as before, is that it is confusing your ItemType member with a .Net ItemType (Such as LiewViewItem.ItemType)
>
>TBH I don't think I'm a fan of the AutoMapper:
>(a) It's slow

Hmm, that may be a problem. I do already notice that forms load quite slow.


>(b) It's too much of a 'black box' relying on naming conventions and reflection.
>
>Seems to me it would be just as easy (and safer) to simply define an explicit cast between the two classes.

For now I am going to try your idea of removing the ItemType as a property in the view model and using Ignore option. Let's see if it will work.
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