Questions tagged [automapper-3]

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

This release was focussed on a separation for platform deployments, code comments and LINQ projection. Release blog and notes give further details.

128 questions
1
vote
0 answers

AutoMapper ignoring IsSourceValueNull when using ForAllMembers

I have the latest 3.1.1 version of AutoMapper. For some reason the IsSourceValueNull when using ForAllMemebers doesn't seem to work or I am expecting a different result: Here is an example of what I am trying to do. Please refrain from commenting on…
DDiVita
  • 4,225
  • 5
  • 63
  • 117
1
vote
1 answer

Mapping Child Collections using AutoMapper

I am using Automapper for making a copy of an object My domain can be reduced into this following example Consider I have a Store with a collection of Location public class Store { public string Name { get; set;} public Person Owner…
frictionlesspulley
  • 11,070
  • 14
  • 66
  • 115
1
vote
2 answers

Automapper with linq how?

Ok, I'm really struggling with finding a good example of what I need to do. So, I'll ask here. Let's say I have a entity class (EF) named Customer and a corresponding view-model class named CustomerViewModel. Using AutoMapper, I have created the…
gilpach
  • 1,367
  • 3
  • 16
  • 34
1
vote
0 answers

Automapper - Not copying from source to destination object correctly. Errors need default constructor

When I map a source object into an existing instance it appears to want to create a new object and not copy into... Here is my test scenario: List domainCustomers = customers.Select(customer => new DomainCustomerProxy( …
retslig
  • 888
  • 5
  • 22
1
vote
1 answer

AutoMapper: int? being mapped to null when there is source has value

I have the following Map created: Mapper.CreateMap(); In this Map, there are some properties which are 'int?' (nullable foreign keys) as, for example IDSUPERVISOR. In order to apply the mapping I use the following…
Farlop
  • 690
  • 1
  • 6
  • 20
1
vote
1 answer

Map single source with array property to list of flat destination

I'm using .NET 4.5 and Automapper 3.0 I have a source object with an array of Child objects as a property: public class Source { public string Name { get; set; } public Child[] Values { get; set; } } public class Child { public string…
squillman
  • 13,363
  • 3
  • 41
  • 60
1
vote
0 answers

Automapper error when running MSTest from command line

I'm using AutoMapper 3.0.0 (.net40) in my project and I have MS Test unit tests. All my tests run fine when I run the tests directly from Visual Studio 2012. But when I run the same unit tests from command line using MSTest.exe the test fails with…
Satish
  • 3,020
  • 7
  • 35
  • 47
0
votes
1 answer

c# Automapper - Sequence of Properties

Classes created as below: public class Base { public int Id { get; set; } } public class Derived:Base { public string Name { get; set; } } Automapper mapping defined as: CreateMap() .ForMember(m => m.Id, opt => opt.MapFrom(r =>…
0
votes
1 answer

Auto Mapper Constructor initialization Mapping Issue

I have the following Mapping configurations:- Initialized Data:- private static IEnumerable InitializeData() { var source= new[] { new Source("John", "Doe", "1111111111"), new Source("Jack",…
Urgen
  • 1,095
  • 3
  • 19
  • 39
0
votes
0 answers

Map two lists using Automapper

I need to map the Fields of My Class to RegisterNewPeopleCommand, but in the third field (passed parameter) I must pass a List of Phones (List ) that is inside the PeopleViewModel class (PeopleViewModel.PeopleListPhones). I need to convert from List…
Master JR
  • 231
  • 2
  • 11
0
votes
1 answer

Is it correct to have constructor dependencies inside an AutoMapper Profile class, can it cause problems during testing?

I am using the static version of AutoMapper. I have some Profile classes where in the constructor there are some dependencies, which in turn have dependencies of their own. So my question is since we set up AutoMapper once, how do I mock these…
Sharthak Ghosh
  • 576
  • 1
  • 9
  • 22
0
votes
0 answers

How to mock behavior of AutoMapper Mapping in Nsubstitute

Currently I have something like this :- var someclass1 = JsonConvert.Deserialize(RandomData); var someclass2 = AutoMapper.Mapper.Map(someclass1); Assert.Equal(someclass2.Count, 1); I know in…
Sharthak Ghosh
  • 576
  • 1
  • 9
  • 22
0
votes
1 answer

Mapper does not contain definition for CreateMap C#

public IEnumerable GetNewNotifications() { var userId = User.Identity.GetUserId(); var notifications = _context.UserNotifications .Where(un => un.UserId == userId) .Select(un => un.Notification) …
Radost
  • 131
  • 1
  • 11
0
votes
1 answer

auto mapping properties from two classes with third class using automapper

I have two classes, say ClassA and ClassB, and I want to map them with ClassC. How can I do it? ClassA has only 1 property and ClassB has 5 properties. ClassC has 6 properties. Situation is something as below: Public ClassC MapRequest(classA id,…
Kapil Garg
  • 51
  • 1
  • 4
0
votes
1 answer

AutoMapperMappingException Get Property name

I've got a custom adapter pattern like so public interface IFoo { byte[] Content{get; set;} } public class FooDTO : IFoo { byte[] Content {get; set;} } public FooAdapter : IFoo { Picture _picture; public FooAdapter(Picture…
johnny 5
  • 19,893
  • 50
  • 121
  • 195
1 2 3
8 9