Questions tagged [automapper-9]

Use this tag for version specific questions about AutoMapper 9 - the convention-based object-to-object mapper and transformer library for .NET. When using this tag also include the more generic [automapper] tag where possible.

32 questions
18
votes
2 answers

Automapper Object reference is required for the non static field, method or property

I recently Upgraded my .net core to 3.0 and Automapper from 6.2 to 9.0. Now the automapper is throwing the following compile time error when using mapper.map inside mapfrom function. CreateMap() .ForMember(dest…
abbs
  • 226
  • 2
  • 3
  • 12
6
votes
1 answer

AutoMapper Version 9.0.0 - No ConfigureMap() Method on IMappingOperationOptions

I'm upgrading a Visual Studio 2019 solution's projects from AutoMapper version 8.0.0 to version 9.0.0. There are a number of places in the code that are calling a ConfigureMap() method. Errors in the build output state: …
markoos
  • 125
  • 1
  • 7
5
votes
4 answers

I keep getting "needs to have a constructor with 0 args or only optional args. (Parameter 'type')"

I am using version 9. I am using a Profile based configuration. When I run the application the Mapper.Map<>() method throws the following exception: JobAssist.Services.ResumeBankMgmt.API.Application.ViewModels.ResumeBankViewModel needs to have a…
Mike Lenart
  • 767
  • 1
  • 5
  • 19
4
votes
1 answer

Upgrading AutoMapper from v6 to v9 and unit testing with Resolution Context

I'm hoping that somebody can help me. We are currently upgrading AutoMapper from v6 to v9 - we would go to v10 but the inability to create new ResolutionContext impacts our unit testing. That said with v9 we are still having the following issue with…
wombat172a
  • 111
  • 6
2
votes
0 answers

Unit test case for Automapper ValueConverter, mocked mapper not returning expected model

I have written valueconverter and wrote a test case for it. When I pass mocked mapper to resolution context, it's not behaving as per the setup. Here is my code - Converter - public class AirlineConverter : IValueConverter { …
shahista inamdar
  • 176
  • 2
  • 12
2
votes
1 answer

Auto mapper Custom resolver source members to destination object list mapping issue

The Scenario is as follows: Source Object: public class personSrc { public string name {get; set;} public string phone {get; set;} public string HomeAddress {get; set;} public string OfficeAddress {get; set;} } Destination…
maces13
  • 305
  • 3
  • 13
2
votes
0 answers

Automapper validate source and destination members

I've been using Automapper but this is my first 9.0 automapper use. I'd like Automapper to complain whenever a new field pops up in the source or the destination and I have no two-way mappings. By trying out I've found out…
Volker
  • 1,753
  • 2
  • 18
  • 28
2
votes
2 answers

AutoMapper: Issues mapping an ImmutableHashSet

I'm trying to Map and ReverseMap an ImmutableHashSet property to an ICollection using AutoMapper. The Automapper successfully maps the ImmutableHashSet property to ICollection but it fails to map the ICollection back to ImmutableHashSet Here is the…
Ankit Vijay
  • 3,752
  • 4
  • 30
  • 53
2
votes
1 answer

AutoMapper - Not working with generics after upgrade from v8 to v9

I have possibly and odd AutoMapper setup that was working before we updated to version 9. We grab data from a database, wrap it in a generic object and then map it to a DTO: //build some models Domain test1 = new Domain() { Id = 1,…
Smithy
  • 2,170
  • 6
  • 29
  • 61
1
vote
1 answer

Map class with abstract property to destination

I'm having some issues mapping a container class that contains an abstract property to my View Model destination class. Mapping Source Classes //Container class public class GiftcardDetailResponse : Response { //Instance of either…
Dillon Drobena
  • 761
  • 1
  • 8
  • 26
1
vote
1 answer

Automapper Queryable Extensions not appearing

I am using the following: EntityFrameworkCore 3.1.2 .Net Standard Library 2.1 Automapper 9.0.0 Automapper.Extension.Microsoft.DependencyInjection 7.0.0 My DI for AutoMapper looks like…
1
vote
1 answer

Automapper AddAfterMapAction not calling method

I am using global configuration for Automapper profile mapping. public class StudentProfile : Profile { public StudentProfile() { CreateMap() .ForMember(dest => dest.school, src => src.Ignore()); …
Fahad Mahmood
  • 350
  • 2
  • 5
  • 20
1
vote
2 answers

Autmapper Call method on every property map

I want to call a specific method xyz() on every property mapped by generic mapper configuration. Is this possible? I am using Automapper v 9. Purpose is to call the method on each property mapped by Automapper to check add remove data at…
Fahad Mahmood
  • 350
  • 2
  • 5
  • 20
1
vote
1 answer

Automapper: map an object inside a Profile using a parameter

I have the following issue using ASP.NET Core 2.2 and Automapper 9.0.0: I have a Entity that I map to a dto, this works fine. Inside that entity are a few entities as well. These cannot be flattened as they are also needed by our client. There is…
Gert Dunon
  • 61
  • 6
1
vote
1 answer

Automapper 9 Configuration

In previous versions of AutoMapper I used to be able to configure AutoMapper like this: public static class AutoMapperFactory { public static IConfigurationProvider CreateMapperConfiguration() { var config = new…
Andrew
  • 2,013
  • 1
  • 23
  • 38
1
2 3