Automapper expression must resolve to top-level member

You are using : Mapper.CreateMap<Source, Destination>() .ForMember( dest => dest.OutputData.Cars, input => input.MapFrom(i => i.Cars)); This won’t work because you are using 2 level in the dest lambda. With Automapper, you can only map to 1 level. To fix the problem you need to use a single level : Mapper.CreateMap<Source, Destination>() .ForMember( dest => dest.OutputData, … Read more

Mapping one source class to multiple derived classes with automapper

Include derived mappings into base mapping: Mapper.CreateMap<Source, DestinationBase>() .ForMember(d => d.Id, op => op.MapFrom(s => s.Id)) // you can remove this .Include<Source, DestinationDerived1>() .Include<Source, DestinationDerived2>(); Mapper.CreateMap<Source, DestinationDerived1>() .ForMember(d => d.Name, op => op.MapFrom(s => s.Text)) .ForMember(d => d.Value2, op => op.MapFrom(s => s.Amount)); Mapper.CreateMap<Source, DestinationDerived2>() .ForMember(d => d.Value, op => op.MapFrom(s => s.Amount)); Usage: Mapper.AssertConfigurationIsValid(); … Read more

How to configure Conditional Mapping in AutoMapper?

Try this Mapper.CreateMap<Source, Target>() .ForMember(dest => dest.Value, opt => opt.MapFrom (src => src.Value1.StartsWith(“A”) ? src.Value1 : src.Value2)); Condition option is used to add conditions to properties that must be met before that property will be mapped and MapFrom option is used to perform custom source/destination member mappings.

Automapper copy List to List

Once you’ve created the map (which you’ve already done, you don’t need to repeat for Lists), it’s as easy as: List<PersonView> personViews = Mapper.Map<List<Person>, List<PersonView>>(people); You can read more in the AutoMapper documentation for Lists and Arrays.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)