Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestModel
- {
- public string A { get; set; }
- public string B { get; set; }
- public bool C { get; set; }
- public bool D { get; set; }
- }
- var model1 = new TestModel
- {
- A = "a",
- B = "b",
- C = true,
- D = false
- }
- var model1 = new TestModel
- {
- A = null,
- B = "b",
- C = false,
- D = true
- }
- var mergedModel = new TestModel
- {
- A = "a",
- B = "b",
- C = true,
- D = true
- }
- Mapper.Initialize(cfg =>
- {
- cfg.CreateMap<TestModel, TestModel>()
- .ForAllMembers(options =>
- {
- options.Condition((source, destination, member) => member != null);
- });
- });
- var mergedModel = Mapper.Map(model1, model2);
Add Comment
Please, Sign In to add comment