Questions tagged [automapper-2]

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

113 questions
0
votes
1 answer

AutoMapper include all properties of a custom List

class SomeObject { public string name {get;set;} } class CustomCollection : List { public int x {get;set;} public string z {get;set;} } class A { public CustomCollection collection { get ; set; } } class B { public…
newbie
  • 1,485
  • 2
  • 18
  • 43
0
votes
1 answer

InvalidCastException while Mapping types MyType to MyType

I'm using AutoMapper 2.2.1 to map different business objects to view models. Now I'm getting a InvalidCastExceptions if I try to map objects which have a property of type CustomList (see code below). The exception says that CustomList cannot be…
Andreas
  • 2,252
  • 1
  • 19
  • 29
0
votes
1 answer

AutoMapper non-destructive list reconciliation?

I have a list on the target object that I want to reconcile against the source. The list is already created, I just want AutoMapper to add/update/delete items from this list, at no time should the list be set to a new object reference. How can I do…
Alwyn
  • 8,079
  • 12
  • 59
  • 107
0
votes
1 answer

Automapper: Hydrate int? based on conditions

I have the following code: [Test] public void ConditionalMapping() { var src = new Sample1 {Age = 1, Number = null}; var dest = new Sample2 {Age = null, Number = 1}; Hydrate(src, dest, false); Assert.That(dest.Age, Is.EqualTo(1)); …
Chi Chan
  • 11,890
  • 9
  • 34
  • 52
0
votes
0 answers

AutoMapperMappingExtensions was unhandled by user

I'm developing an applications, it involves a dropdownlist with image and text in MVC4. For instance, displaying image (Country Flag) with name of the country. I've used AutoMapper, IEnumerable. It says error as AutoMapperMappingExtensions was…
Infanty Rajan
  • 21
  • 1
  • 3
0
votes
1 answer

How to pull in data from another table in repository or in automapper?

I am essentially am trying to find a clean way to pull in data from another table. Below is a simplified version of my model. My goal is to put the platform name in the userplatform. I would like the cleanest way to do this so I assume with…
0
votes
1 answer

Saving Model is cascading update when I only want the main model updated

I am using C# Web API and I am using the repository standard to save to the database. Below is a shortened example I am using to update the database. So I use automapper to flatten between user to getuser the region. So when I try to update for…
0
votes
3 answers

using AutoMapper to map a viewmodel to a model interface

I have created a AutoMapper mapping configuration class code below: public static class MilitaryBrochureViewModelMapper { public static void Configure() { ConfigureMilitaryBrochureMapping(); } private static void…
CryoFusion87
  • 796
  • 1
  • 8
  • 28
0
votes
1 answer

AutoMapper suggestion required

I have below classes class Contact { string FirstName; string LastName; List ContactNumbers; } class Phone { string Number; PhoneType Type; } enum PhoneType { Home, Work, Fax } class Source { …
techspider
  • 3,370
  • 13
  • 37
  • 61
0
votes
2 answers

Random "Missing type map configuration or unsupported mapping." Error in Automapper

Please see this post for the solution. Ok, I finally figured it out. The: AppDomain.CurrentDomain.GetAssemblies() piece of my code sometimes does not get my mapping assembly so while it is missing I get an error. Replacing this code by forcing…
Kadir.K
  • 366
  • 4
  • 17
0
votes
0 answers

How to use AutoMapper for a source class with multiple view classes which are derived from each other

My history is mainly C/C++, but I've recently been thrown into the c#/.net world. Please be gentle. I'm trying to use automapper to map a single domain entity class to MULTIPLE views. So, it is like this: class DomainEntity { } class…
Matthew Eshleman
  • 674
  • 5
  • 15
0
votes
2 answers

Is it possible to get LINQ projections from WCF service?

Automapper has a very nice extensions for getting projections. In BL of our application we can just define methods like this: IEnumerable GetProjections() { return…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
0
votes
0 answers

AutoMapper 2.1.267.0 does not map simple int? property

I have the following classes Source: public class NewBusinessSubmission { //other properties public int? TermTypeId { get; set; } } Destination: NewBusinessSubmission class inherits from the PolicyTransaction class shown below (yes…
Alper
  • 663
  • 1
  • 7
  • 24
0
votes
1 answer

Autoproject several sequences into the main ViewModel via Automapper

I'm trying to auto project from SQL server with Automapper some data into my view models. The view model I have is: public sealed class WorkstationViewModel { public int Id { get; set; } public string Name { get; set; } public string…
AgentFire
  • 8,944
  • 8
  • 43
  • 90
0
votes
1 answer

AutoMapper Throwing Exception When Mapping Against Two Different Collection Types

I'm writing a ASP.NET Web API service which uses AutoMapper for object mapping. I'm building this service against the AbleCommerce shopping cart software. The service (destination) classes at issue track users and their addresses. public class…
Neil T.
  • 3,308
  • 1
  • 25
  • 30