automapper-6

Automapper nested Collections without setter

不羁的心 提交于 2020-08-25 03:38:22
问题 I have this code snippet running on LinqPad (C# program) with Automapper Nuget package 6.1.1 already included: void Main() { Mapper.Initialize(cfg => { cfg.CreateMap<Top, TopDto>().ReverseMap(); }); Mapper.AssertConfigurationIsValid(); var source = new TopDto { Id = 1, Name = "Charlie", Nicks = new List<string> { "Fernandez", "Others" } }; var destination = Mapper.Map<Top>(source); destination.Dump(); } // Define other methods and classes here public class Top { public Top() { Nicks = new

Automapper nested Collections without setter

…衆ロ難τιáo~ 提交于 2020-08-25 03:37:13
问题 I have this code snippet running on LinqPad (C# program) with Automapper Nuget package 6.1.1 already included: void Main() { Mapper.Initialize(cfg => { cfg.CreateMap<Top, TopDto>().ReverseMap(); }); Mapper.AssertConfigurationIsValid(); var source = new TopDto { Id = 1, Name = "Charlie", Nicks = new List<string> { "Fernandez", "Others" } }; var destination = Mapper.Map<Top>(source); destination.Dump(); } // Define other methods and classes here public class Top { public Top() { Nicks = new

Automapper does not map properly null List member, when the condition != null is specified

点点圈 提交于 2020-07-18 05:12:07
问题 There is a problem when I try to map a null list (member) of an object, considering that I specified: .ForAllMembers(opts => opts.Condition((src, dest, srcMember) => srcMember != null )); cfg.AllowNullCollections = true; // didn't help also short example from code: gi.PersonList = new List<Person>(); gi.PersonList.Add(new Person { Num = 1, Name = "John", Surname = "Scott" }); GeneralInfo gi2 = new GeneralInfo(); gi2.Qty = 3; Mapper.Map<GeneralInfo, GeneralInfo>(gi2, gi); gi.PersonList.Count =

Automapper does not map properly null List member, when the condition != null is specified

 ̄綄美尐妖づ 提交于 2020-07-18 05:11:19
问题 There is a problem when I try to map a null list (member) of an object, considering that I specified: .ForAllMembers(opts => opts.Condition((src, dest, srcMember) => srcMember != null )); cfg.AllowNullCollections = true; // didn't help also short example from code: gi.PersonList = new List<Person>(); gi.PersonList.Add(new Person { Num = 1, Name = "John", Surname = "Scott" }); GeneralInfo gi2 = new GeneralInfo(); gi2.Qty = 3; Mapper.Map<GeneralInfo, GeneralInfo>(gi2, gi); gi.PersonList.Count =

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

夙愿已清 提交于 2019-12-25 09:35:00
问题 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 for Created and Updated in Descriptions are lost. The values that do come in via the view model are all updated correctly. What am I doing wrong? Automapper also loses Entity Framework 6 mapping for Article since those values are lost as well.

Automapper - Mapper already initialized error

独自空忆成欢 提交于 2019-12-18 05:27:19
问题 I am using AutoMapper 6.2.0 in my ASP.NET MVC 5 application. When I call my view through controller it shows all things right. But, when I refresh that view, Visual Studio shows an error: System.InvalidOperationException: 'Mapper already initialized. You must call Initialize once per application domain/process.' I am using AutoMapper only in one controller. Not made any configuration in any place yet nor used AutoMapper in any other service or controller. My controller: public class

Automapper 8 mapping not working properly

三世轮回 提交于 2019-12-13 10:32:59
问题 I have two model classes, when I try to map different properties of different name by using Automapper ForMember method. It throws an automapper configuration validation exception on the mapping of different property. I have tried a lot but It does not help.I do not know why It is throwing an exception when I try to map Quantity property with Quntity property. but when I put same name of the property in both the model classes then it works Below is located all the model classes, exception and

Automapper 6.0.2.0, Mapper.Map() throws StackOverflow when mapping Child Entities

谁说我不能喝 提交于 2019-12-11 14:08:34
问题 Getting straight to the point, I've got the following Models: public abstract class ControlData { public DateTime CreatedDate { get; set; } public int CreatedById { get; set; } [ForeignKey("CreatedById")] public Collaborator CreatedBy { get; set; } public DateTime? UpdatedDate { get; set; } public int? UpdatedById { get; set; } [ForeignKey("UpdatedById")] public Collaborator UpdatedBy { get; set; } } [Table("My_Position_Table")] public class Position : ControlData { [Key] [Column("PositionId"