Created
February 28, 2017 15:01
-
-
Save cryo75/ea78d9251b9159137a5fd038a83b160b to your computer and use it in GitHub Desktop.
Error on flatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Nested | |
{ | |
public int Property1 {get;set;} | |
public string Property2 {get;set;} | |
} | |
public class Model | |
{ | |
public int Id { get; set; } | |
public int ParentId { get; set; } | |
public int NestedId { get; set; } | |
public int Position { get; set; } | |
public bool? IsOk { get; set; } | |
public virtual Nested Nested { get; set; } | |
} | |
public class Dto | |
{ | |
public Guid Guid { get; set; } | |
public Guid ParentGuid { get; set; } | |
public int Id { get; set; } | |
public int ParentId { get; set; } | |
public int NestedId { get; set; } | |
public int Position { get; set; } | |
public bool? IsOk { get; set; } | |
[XmlIgnore] | |
public int Property1 { get; set; } | |
[XmlIgnore] | |
public string Property2 { get; set; } | |
} | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<model, dto>() | |
.ForMember(dest => dest.Guid, option => option.Ignore()) | |
.ForMember(dest => dest.ParentGuid, option => option.Ignore()) | |
.ForMember(dest => dest.Property1, option => option.MapFrom(src => src.Nested.Property1)) | |
.ForMember(dest => dest.Property2, option => option.MapFrom(src => src.Nested.Property2)) | |
.ReverseMap(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment