31911

Automapper CreateMissingTypeMaps property Warning

Question:

I think this is a repeated Question but i am unable to resolve it. here is my mapping.

UserProfileVM model = AutoMapper.Mapper.DynamicMap<UserProfileVM>(objUser);

But here AutoMapper gives warning.

I tried to add MapperConfiguration, but i have no idea how to use it in DynamicMap<>().

var config = new MapperConfiguration(cfg => { cfg.CreateMissingTypeMaps = true; });

Now how to use my <strong>config</strong> variable for dynamic map?

Or is there any global setting for these issue because i used mapper for many times in my application.

Answer1:

Initialize static AutoMapper using a certain configuration (recommended for the usage you have show):

Mapper.Initialize(cfg => cfg.CreateMissingTypeMaps = true);

Or create instance of AutoMapper from a configuration:

var config = new MapperConfiguration(cfg => { cfg.CreateMissingTypeMaps = true; }); IMapper mapper = config.CreateMapper();

<a href="https://github.com/AutoMapper/AutoMapper/wiki/Static-and-Instance-API#unsupported-operations" rel="nofollow">AutoMapper Static and Instance API</a>

Recommend

  • How to use AutoMapper to map objects by order defined in the class?
  • Unable to open shell: Ansible v2.3.1.0
  • Convert member variable name to a string
  • Java Quartz scheduled Job - disallow concurrent execution of Job
  • Programmatically login in dotnetnuke
  • Installing pygrib Package
  • Ebnf – Is this an LL(1) grammar?
  • How to define a custom type error within a type family for a constraint that uses type equality?
  • Obfuscating Android app with CORBA
  • SAS: Print to Log AND View Live Log Window Simultaneously
  • Youtube iframe api: 'onReady', 'onStateChange' not firing in IE 8
  • remote phpmyadmin can't login but mysql client can
  • Iterate through multilevel boost tree
  • Date format jqplot categoryaxisrenderer after ticks add
  • Setting up Let's encrypt with Go - handshake errors
  • ionic pro package failure: Failed to install android SDK Platform 26
  • Querying via NHibernate without an N+1 - sample included
  • Datatables server-side processing INNER JOIN or multiple tables
  • How should I organize my c# solution?
  • Why do Unicode characters show up properly in database, but as ? when printed in Java via Hibernate?
  • Where should I store a file in Android?
  • Generate list with conditional items
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • C: Incompatible pointer type initializing
  • C# - Serializing and deserializing static member
  • Java applet as stand-alone Windows application?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Error creating VM instance in Google Compute Engine
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Android Google Maps API OnLocationChanged only called once
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?