Questions tagged [automapper-6]

Use this tag for version specific questions about AutoMapper 6 - 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.

117 questions
3
votes
2 answers

AutoMapper - map to derived objects depend on condition

I want to map source class to derived (from abstract) destination classes depend on value of some property. I have the following source classes: public partial class ApplicationDriver { public virtual ICollection
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
3
votes
1 answer

Does not recognize Add Collection Mappers from automapper.collection

I try to use automapper.collection but in the Mapper.Initialize method the AddCollectionMappers method is not recognized I'm using .net 4.7, automapper 6.1.1, automapper.collection 3.1.1 Thank you. enter image description here
3
votes
1 answer

How to upgrade Automapper 4.2.1 to 6.1.1 in solution. What I'm missing?

I'm update my automapper 4.2.1 from nuget and it was install automapper 6.1.1 version. In old version all mapping works properly but when I update my automapper library mapping didn't work it says that Missing type map configuration or unsupported…
Bora Oktekin
  • 33
  • 1
  • 6
3
votes
3 answers

Integration Testing with AutoMapper fails to initialise configuration

Frameworks & Packages .NETCoreApp 1.1 Xunit 2.2.0 AutoMapper 6.0.2 Microsoft.AspNetCore.TestHost 1.1.1 Microsoft.NET.Test.Sdk 15.0.0 Integration Test public class ControllerRequestsShould { private readonly TestServer _server; private…
2
votes
0 answers

Automapper - Cannot ignore a property when mapping to a list existing entities

I have two class TenantRestrictSourceEntity, TenantRestrictSource and mapper profile CreateMap() .ForMember(dest => dest.Tenant, opt => opt.Ignore()); public class…
Hung Quach
  • 2,079
  • 2
  • 17
  • 28
2
votes
1 answer

Configuring convention for all members with type in automapper

All my domain models have field public CurrencyId CurrencyId {get; set;}. All my view models have filed public CurrencyVm Currency {get; set;}. Automapper knows how to Map(CurrencyId). How can I setup automatic convention, so I do not…
Shadow
  • 2,089
  • 2
  • 23
  • 45
2
votes
0 answers

Automapper how to ignore missing properties in destination child properties

I've followed this answer (http://stackoverflow.com/a/31182390/58508) to ignore missing properties in destination and it works fine, but I don't know how to do the same for children collection properties. For example, I've a CustomerViewModel and…
Jose L. Garcia
  • 316
  • 5
  • 14
2
votes
2 answers

Automapper UseDestinationValue() or Ignore() both setting integer destination value to 0

First of all there are several similar questions and I have tried looking at them every where but none of them worked . I have this mapping code var updateEntities = await _dbContext.AnswerAnchors.Where(x => x.SurveyResultId ==…
Joy
  • 6,438
  • 8
  • 44
  • 75
2
votes
1 answer

Setting up AutoMapper(6.2.2) first time in .NET Project

Wanted to use AutoMapper to deal with some 'monkey' code. It works right of the bat; now looking to set up all the mapping in one place. So, I have: A static class AutoMapperConfiguration in AppStart folder. A static Configure method in which I…
Shwrk
  • 173
  • 1
  • 11
2
votes
2 answers

Automapper Round All Decimal Type Instances

I need a way to add rounding to my automapper configuration. I have tried using the IValueFormatter as suggested here: Automapper Set Decimals to all be 2 decimals But AutoMapper no longer supports formatters. I don't need to covert it to a…
Don Sartain
  • 557
  • 9
  • 25
2
votes
0 answers

Automapper Mapping of simple object to more complex nested type

I am in the process of a refactor and utilizing AutoMapper (6.2.1) to help us in formatting of API returns that conform to a specific contract. The DTO objects we are using internally are meant to simplify our understanding of the data before…
Schanckopotamus
  • 781
  • 2
  • 6
  • 20
2
votes
0 answers

Automapper 6 CustomList to CustomList2 not mapping items

I have have two PagedList types. Data.PagedList implements IList, ViewModels.PagedList inherits List. I'm trying to map from Data.PagedList to ViewModels.PagedList. I have an open generic mapping for the two…
xr280xr
  • 12,621
  • 7
  • 81
  • 125
2
votes
1 answer

Automapper Map ICollection to single concrete object

how can i map a Collection of Objects to a single object of an concrete type using automapper? Sample: Model: public class SystemOptionsModel { public string OptionID { get; set; } public string OptionValue { get; set; } } DTO: public class…
macostobu
  • 832
  • 7
  • 12
2
votes
2 answers

Automapper for member condition

I am using auto mapper 6.1 and I want to map some values from one object to another, but there is a condition that those values can not be null and not all object properties are supposed to be mapped if so I could easily use ForAllMembers…
Wojciech Szabowicz
  • 3,646
  • 5
  • 43
  • 87
2
votes
0 answers

Automapper configuration with cast in field name

Why this mapping in the example is not map correctly. When I change the suffix CAST to something else (CAST1) it maps correctly. How should I set the mapper to map correctly with the suffix CAST? public class Class1 { public string OBEC { get;…
kubo
  • 492
  • 7
  • 19