public static void Start() { Debug.WriteLine("\n\n***** Demo ControlMerge *****\n"); var source = PersonDtoSource.GetPersonDtos(); var destination = PersonEntitySource.GetPersonEntities(); source.Display("Source DTOs"); destination.Display("Destination entities"); source.ControlMerge(destination, src => src.GetEntityId(), dest => dest.Id, add: src => Debug.WriteLine($"Adding : {src.Name}"), update: (src, dest) => Debug.WriteLine($"Updating : {dest.Name} => {src.Name}"), delete: dest => Debug.WriteLine($"Deleting : {dest.Name}")); }
public static void Start() { Debug.WriteLine("\n\n***** Demo MergeInto Without Updates *****\n"); var source = PersonDtoSource.GetPersonDtos(); var destination = PersonEntitySource.GetPersonEntities().ToList(); source.Display("Source DTOs"); destination.Display("Destination entity collection (before merge)"); source.MergeInto(destination, getKeyFromSource: src => src.GetEntityId(), getKeyFromDest: dest => dest.Id, mapAdd: src => new Person(src.GetEntityId(), src.Name)); destination.Display("Destination entity collection (after merge)"); }
public static void Start() { Debug.WriteLine("\n\n***** Demo MergeInto With Conditionals *****\n"); var source = PersonDtoSource.GetPersonDtos(); var destination = PersonEntitySource.GetPersonEntities().ToList(); source.Display("Source DTOs"); destination.Display("Destination entity collection (before merge)"); new InPlacePersonMerger() .FromSource(source) .OnAdding(src => !src.Name.StartsWith('A')) .OnDeleting(dest => !dest.Name.StartsWith('S')) .MergeInto(destination); destination.Display("Destination entity collection (after merge)"); }
public static void Start() { Debug.WriteLine("\n\n***** Demo Merge Without Updates *****\n"); var source = PersonDtoSource.GetPersonDtos(); var destination = PersonEntitySource.GetPersonEntities(); source.Display("Source DTOs"); destination.Display("Destination entities"); var result = source.Merge(destination, getKeyFromSource: src => src.GetEntityId(), getKeyFromDest: dest => dest.Id, mapAdd: src => new Person(src.GetEntityId(), src.Name)); result.Display("Result entities"); }
public static void Start() { Debug.WriteLine("\n\n***** Demo Merge With Conditionals *****\n"); var source = PersonDtoSource.GetPersonDtos(); var destination = PersonEntitySource.GetPersonEntities(); source.Display("Source DTOs"); destination.Display("Destination entities"); var result = source.Merge(destination, getKeyFromSource: src => src.GetEntityId(), getKeyFromDest: dest => dest.Id, mapAdd: src => new Person(src.GetEntityId(), src.Name), mapUpdate: (src, dest) => new Person(dest.Id, src.Name), onAdding: src => !src.Name.StartsWith('A'), onUpdating: (src, dest) => dest.Name != "Jim", onDeleting: dest => !dest.Name.StartsWith('S')); result.Display("Result entities"); }