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
1
vote
0 answers

How to make Automapper ignore records based on a value of a field

Hi I am trying to use Automapper 6 and want to ignore records based on specific value in a field. I wish there was a way to skip records like so: CreateMap() .ForMember(dest => dest,…
Anand
  • 1,387
  • 2
  • 26
  • 48
1
vote
1 answer

Can't configure ReverseMap in AutoMapper

I'm a AutoMapper newb. My mappings are not working as expected and I'm sure I'm doing somthing wrong but can't figure it out. Sorry if this question is confusing, but i'll do my best to be clear. Lets say we have three classes: public class…
tmatuschek
  • 608
  • 4
  • 15
1
vote
0 answers

How to pass a variable to AutoMapper at runtime for on the fly calculation?

I am trying to use AutoMapper 6.3 to allow me to auto map my models into view-models. First I registered my AutoMapper instance to my IUnitContainer like so var mapper = new MapperConfiguration(cfg => { cfg.CreateMap
Junior
  • 11,602
  • 27
  • 106
  • 212
1
vote
1 answer

AutoMapper and IDataReader

I would like to map data from IDateReader to some class but can not do it simply. I wrote the following code: cfg.CreateMap() .ForMember(x => x.Id, opt => opt.MapFrom(rdr => rdr["Id"])) .ForMember(x => x.Name, opt…
Pupkin
  • 1,211
  • 3
  • 13
  • 30
1
vote
1 answer

AutoMapper : Open - Closed Principle

I got the code from the given link AutoMapper Code for Open Closed Principle Code I am trying to use it in my project but I am stuck due to Static API has been removed from AutoMapper version 4.2.0. For reference see this Please can any one help me…
C J
  • 429
  • 1
  • 10
  • 34
1
vote
1 answer

AutoMapper with a complex EF Entity

I have a basic table with a few FK references. So when I retrieve an entity for an update operation; that entity contains ICollectionsof related entites. I also have a main ViewModel inside which each entity is a sub viewModel. My aim is to use…
Shwrk
  • 173
  • 1
  • 11
1
vote
0 answers

Automapper custom mapping issue

I am first time user of Automapper using version 6.2.2. I am try to find out how can I map below DB entity to custom DTO. public partial class vw_Owner { public int Space_Id { get; set; } public string Owner_ID { get; set; } …
sunder
  • 1,803
  • 4
  • 29
  • 50
1
vote
0 answers

How to map a POCO with a Dictionary and an external parameter to a new EF model

I'm working on a solution that needs to convert a POCO to a concrete data model I'm using with Entity Framework Code First. The Original POCO looks like this: public class Original { public string Name { get; set; } public string Test { get;…
Anon Dev
  • 1,361
  • 3
  • 14
  • 29
1
vote
0 answers

AutoMapper: Breacking syntax issue from 4.x to 6.2

I've updated AutoMapper from 4.2.x to 6.2.0. I'm getting some breaking syntax compiler errors: this.CreateMap() .ConstructUsing((Func)(ctx => new Act())) .ForMember( //...; I'm getting…
Jordi
  • 20,868
  • 39
  • 149
  • 333
1
vote
0 answers

ASP.NET MVC View classes and null

I have a complex structure with nested view model classes: public class ApplicationDriverFormVM : IValidatableObject { [Required] public string Sign { get; set; } public string Company { get; set; } public…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
1
vote
1 answer

Ignore mapping for all members with different types and same name, using newest version of Automapper(6.1.1)

How can I ignore mapping if some properties have different type with same name? By default it's throwing error. I found some answers for an older versions of automapper but they are not working with the newest. For example one property is string the…
BladeMaster
  • 320
  • 2
  • 9
1
vote
1 answer

Self referencing loop causing stack overflow with map

According to the documentation PreserveReferences should be set automatically whenever possible for AutoMapper. Starting from 6.1.0 PreserveReferences is set automatically at config time whenever…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
1
vote
1 answer

C# Entity Framework 6 - AutoMapper 6 - Collections/List - Add and Update works but removing item throws an error

As the title says I can add and update but when it comes to deleting I get an error. The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
1
vote
2 answers

C# Automapper 6.1.1 - Collection/List destination properties loses values Entity Framework 6

I have a problem when mapping collections with Automapper 6 and I can't find a solution. In the updatedArticle object below I have the old Created and Updated values left after mapping since they do not exist on the view model. However the values…
Ogglas
  • 62,132
  • 37
  • 328
  • 418
1
vote
2 answers

Why does Automapper map Driver.Name to DriverName automatically

I have the following classes: public partial class ScheduledDeduction { public int ID { get; set; } public int DriverId { get; set; } public string Description { get; set; } public DateTime DateTime { get; set; } public…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159