public static Expression Create( EnumerablePopulationBuilder builder, IObjectMappingData enumerableMappingData) { if (builder.TargetElementsAreSimple) { builder.AssignSourceVariableTo(s => s.SourceItemsProjectedToTargetType().ExcludingTargetItems()); builder.AssignTargetVariable(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); } if (builder.ElementsAreIdentifiable) { builder.CreateCollectionData(); builder.MapIntersection(enumerableMappingData); builder.AssignSourceVariableTo(s => s.CollectionDataNewSourceItems()); builder.AssignTargetVariable(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); } builder.AssignSourceVariableToSourceObject(); builder.AssignTargetVariable(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); }
public Expression GetPopulation( EnumerablePopulationBuilder builder, IObjectMappingData enumerableMappingData) { if (builder.ElementTypesAreSimple) { if (builder.TargetTypeHelper.IsReadOnly) { builder.PopulateTargetVariableFromSourceObjectOnly(); return(builder); } builder.AssignSourceVariableFrom(s => s.SourceItemsProjectedToTargetType()); builder.AssignTargetVariable(); builder.RemoveAllTargetItems(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); } if (builder.ElementsAreIdentifiable) { builder.CreateCollectionData(); builder.MapIntersection(enumerableMappingData); builder.AssignSourceVariableFrom(s => s.CollectionDataNewSourceItems()); builder.AssignTargetVariable(); builder.RemoveTargetItemsById(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); } builder.AssignSourceVariableFromSourceObject(); builder.AssignTargetVariable(); builder.RemoveAllTargetItems(); builder.AddNewItemsToTargetVariable(enumerableMappingData); return(builder); }