Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error in AutoMapper
Message
De
18/08/2014 12:55:41
 
 
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:
01606023
Vues:
39
>>I'm still not clear what you regard as the 'Model' but in the context of the AutoMapper problem Models, Views and ViewModels are irrelevant
>>
>>I've asked a couple of times if you could just post the definition of the AutoMapper destination class. Is it by any chance inheriting from ListView ?
>>
>>You're original post shows that the exception was seeing an 'ItemType.ItemType' - which you obviously don't have in your class. But ItemType is a property of ListViewItem.
>
>Your suggestion of using Ignore did fix the problem, thanks again.
>
>I am not sure what do you mean by definition of the destination class.
>
>This is what I have right now in the AutoMapper.config file
>
>
>  Mapper.CreateMap<ItemForDualListViewModel, Siriusware.Models.Items>()
>                 .ForMember(dest => dest.Department,
>                    opt => opt.ResolveUsing<TrimStringResolver>().FromMember(source => source.Department))
>                 .ForMember(dest => dest.ItemType, opt => opt.Ignore())
>                  .ForMember(dest => dest.Category, opt => opt.ResolveUsing<TrimStringResolver>().FromMember(src => src.Category))
>                 .ForMember(dest => dest.Descrip, opt => opt.ResolveUsing<TrimStringResolver>().FromMember(src => src.ItemDescrip))
>                  .ForMember(dest => dest.Item, opt => opt.ResolveUsing<TrimStringResolver>().FromMember(src => src.Item))
>                   .ForMember(dest => dest.ItemId, opt => opt.MapFrom(source => source.ItemId)) ;
>
>As you see, I added Ignore option.
>
>The ItemForDulaListViewModel is defined as
>
>
> public class ItemForDualListViewModel
>    {
>        public string Department { get; set; }
>
>        public string Category { get; set; }
>        
>        public string DepartmentNameHash { get; set; }
>
>        public string CategoryNameHash { get; set; }
>
>        public string ItemNameHash { get; set; } //hash of Item
>
>        //public Byte ItemType { get; set; }
>
>        public bool Hidden { get; set; }
>
>        public int ItemId { get; set; }
>
>        public string Item { get; set; }
>
>        private string descrip { get; set; }
>
>        public string ItemDescrip
>        {
>            get { return descrip; }
>            set { descrip = value; }
>        }
>
>        public string Descrip
>        {
>            get
>            {
>                return string.Format("{0} [{1},{2},{3}]", descrip, Department, Category, Item);
>            }
>            set
>            {
>                descrip = value;
>            }
>        }
>    }
>}
>
>So, as you see, it doesn't have a base class.

Isn't that the source class - I asked about the destination (Siriusware.Models.Items ? )
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform