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
0
votes
0 answers

Automapper common map part

I.e. I have the following map class: public class AutoMapperAddress : AutoMapper.Profile { public AutoMapperAddress() { CreateMap(); } } then I should use it in other places, i.e: public…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
0
votes
0 answers

Mapping nested objects where nested different types have different property names in AutoMapper

I am trying to map one nested object to another like the below example. I can easily map BobAge to JimAge etc. But how do I map Bobs Collection to Jims collection. This can go n levels deep. Thanks very much public class Bob { public int BobAge…
Larry R
  • 43
  • 6
0
votes
0 answers

Automapper Base type, dervied type DTO Mapping

I have the following classes: public class Entity { } public class Company : Entity { } public class Person : Entity { } public class SomeOther { public Entity A { get; set; } } And the following DTOs: public class EntityDTO { } public…
0
votes
0 answers

AutoMapper ignore all unmapped properties from all destinations

We have something below in AutoMapper public class AutomapperConfigure : IAutomapperConfigure { public void Config() { Mapper.Initialize(x => { x.AddGlobalIgnore("EmployeeId"); …
Sukesh Marla
  • 178
  • 11
0
votes
1 answer

AutoMapper Update UseDestinationValue Not Working as expected on Virtual Properties

Struggling to get AutoMapper (6.1.1) to work in this scenario of attempting to update an existing Vendor and associated Vendor Contacts. I've tried using .ignore() and .UseDestinationValues() on the related entities, both to no avail. Here's what…
crichavin
  • 4,672
  • 10
  • 50
  • 95
0
votes
1 answer

AutoMapper to map a child list object

I'm using an generic method to map two classes using Automapper My generic methods public class AutoMapperConfiguration { public MapperConfiguration Configure() where TSource:class where TDestination:class { …
Kumar
  • 303
  • 6
  • 17
0
votes
1 answer

Does Automapper allow disabling the (auto-)flattening?

According to documentation Automapper performs an automatic mapping besides the "normal" (property to property within mapable types). However this functionality caused some unintentional behavior when dealing with some DTO within Entity Framework…
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
0
votes
0 answers

AutoMapper 6.2.2 Error Mapping Types

I'm trying to Map 2 types by using Automapper var userRightInternal = Mapper.Map(userRight, dest => dest.ConfigureMap().ForMember(p => p.PricingModel, m => m.Ignore())); But i'm still getting the following…
0
votes
1 answer

Dynamic Ignore Member in Automapper 6.2.2

When i did this TypeMap typeMap = (TypeMap)mappingExpression.GetType().GetField("_typeMap", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(mappingExpression); AutoMapper 4.0.4 was getting the typeMap successfully. But in the automapper…
Ramos
  • 13
  • 5
0
votes
0 answers

Automapper not mapping ID property of compose object when object is null

I am using Automapper 6.2.2.0, which I think is the latest, in my web project (ASP.NET WebForms) and also in my Business layer, here is what Automapper is not mapping and don't know why: Here is the relationship in the database, also exist the…
ddieppa
  • 5,866
  • 7
  • 30
  • 40
0
votes
0 answers

AutoMapper inline mapping throwing mapper not initialized

I'm trying to use AutoMapper in a API wrapper class library project to map from API models to our domain models. While looking at the AutoMapper documentation I ran into the inline mapping feature. Documentation says: AutoMapper creates type maps…
Marko
  • 12,543
  • 10
  • 48
  • 58
0
votes
0 answers

AutoMapper Ignore the Mapping Conditionally when the List type of property in ViewModel is null

I have the view model as below: public class CarViewModel { public Guid Id { get; set; } public string CarName { get; set; } public List Engine { get; set; } } public class EngineTypeViewModel { public int Id {…
Rasik
  • 1,961
  • 3
  • 35
  • 72
0
votes
1 answer

How to trigger AutoMapper to map a model using linq syntax?

I am trying to use AutoMapper 6.3 to allow me to auto map my model into viewmodels. First I registered my AutoMapper instance to my IUnitContainer like so var mapper = new MapperConfiguration(cfg => { …
Junior
  • 11,602
  • 27
  • 106
  • 212
0
votes
1 answer

How to create complex mapping using AutoMapper?

I have the following Entity-Models public class Blog { public int Id { get; set;} public string Title { get; set; } public string Body { get; set; } [ForeignKey("Category")] public int? CategoryId { get; set; } public…
Junior
  • 11,602
  • 27
  • 106
  • 212
0
votes
1 answer

How do I unittest when having an automapper map to existing object and using nsubstitute

I am using Automapper 6.2.1 and by that removed all statics and instead I am injecting IMapper. I am using NSubstitute for mocking. I have a bit of code where I map two existing objects. public class Person1 { public string Value1 { get;…
Per
  • 1,393
  • 16
  • 28