Last active
May 10, 2019 12:24
-
-
Save ms-lemos/ba48540c6bdb21b2582f7d5f9d1423da to your computer and use it in GitHub Desktop.
This file contains 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 ViewModel | |
{ | |
public Guid Id { get; set; } | |
public Status? Status { get; set; } | |
} | |
public class Model | |
{ | |
public Guid Id { get; set; } | |
public Status Status { get; set; } | |
} | |
public enum Status | |
{ | |
Pending, | |
Processing, | |
Completed | |
} | |
private static void Initialize() | |
{ | |
Mapper.Initialize(cfg => | |
{ | |
cfg.CreateMap<ViewModel, Model>() | |
.ForAllMembers(o => o.Condition((source, destination, member) => member != null)); | |
}); | |
} | |
public static void MergeObject(ViewModel source, Model destination) | |
{ | |
Mapper.Map(source, destination); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment