Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerCarlson1 committed Jun 17, 2017
2 parents 1807656 + f7057bb commit b02ca4f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ task compile -depends clean {
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

echo "build: Tag is $tag"
echo "build: Package version suffix is $version"
echo "build: Package version suffix is $suffix"
echo "build: Build version suffix is $buildSuffix"

exec { .\.nuget\NuGet.exe restore $base_dir\AutoMapper.Collection.sln }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Collection Add/Remove/Update support for AutoMapper. AutoMapper.Collection adds EqualityComparison Expressions for TypeMaps to determine if Source and Destination type are equivalent to each other when mapping collections.</Description>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>3.0.1</VersionPrefix>
<Authors>Tyler Carlson</Authors>
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<AssemblyName>AutoMapper.Collection-Signed</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

<PropertyGroup>
<Description>Collection updating support for EntityFramework with AutoMapper. Extends DBSet&lt;T&gt; with Persist&lt;TDto&gt;().InsertUpdate(dto) and Persist&lt;TDto&gt;().Delete(dto). Will find the matching object and will Insert/Update/Delete.</Description>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>3.0.1</VersionPrefix>
<Authors>Tyler Carlson</Authors>
<TargetFramework>net45</TargetFramework>
<AssemblyName>AutoMapper.Collection.EntityFramework</AssemblyName>
<PackageId>AutoMapper.Collection.EntityFramework</PackageId>
<PackageIconUrl>https://s3.amazonaws.com/automapper/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/AutoMapper/Automapper.Collection</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/AutoMapper/AutoMapper.Collection/blob/master/LICENSE.txt</PackageLicenseUrl>
<Version>3.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

<PropertyGroup>
<Description>Collection updating support for LinqToSQL with AutoMapper. Extends Table&lt;T&gt; with Persist&lt;TDto&gt;().InsertUpdate(dto) and Persist&lt;TDto&gt;().Delete(dto). Will find the matching object and will Insert/Update/Delete.</Description>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>3.0.1</VersionPrefix>
<Authors>Tyler Carlson</Authors>
<TargetFramework>net45</TargetFramework>
<AssemblyName>AutoMapper.Collection.LinqToSQL</AssemblyName>
<PackageId>AutoMapper.Collection.LinqToSQL</PackageId>
<PackageIconUrl>https://s3.amazonaws.com/automapper/icon.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/AutoMapper/Automapper.Collection</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/AutoMapper/AutoMapper.Collection/blob/master/LICENSE.txt</PackageLicenseUrl>
<Version>3.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/AutoMapper.Collection.Tests/MapCollectionWithEquality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public void Should_Update_Existing_Item()
Mapper.Map(dtos, items.ToList()).Should().HaveElementAt(0, items.First());
}

public void Should_Be_Fast_With_Large_Lists()
{
var dtos = new object[100000].Select((_, i) => new ThingDto {ID = i}).ToList();

var items = new object[100000].Select((_, i) => new Thing { ID = i }).ToList();

Mapper.Map(dtos, items.ToList()).Should().HaveElementAt(0, items.First());
}

public void Should_Work_With_Null_Destination()
{
var dtos = new List<ThingDto>
Expand Down
3 changes: 1 addition & 2 deletions src/AutoMapper.Collection/AutoMapper.Collection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Description>Collection Add/Remove/Update support for AutoMapper. AutoMapper.Collection adds EqualityComparison Expressions for TypeMaps to determine if Source and Destination type are equivalent to each other when mapping collections.</Description>
<VersionPrefix>3.0.0</VersionPrefix>
<VersionPrefix>3.0.1</VersionPrefix>
<Authors>Tyler Carlson</Authors>
<TargetFrameworks>net45;netstandard1.1;netstandard1.3</TargetFrameworks>
<AssemblyName>AutoMapper.Collection</AssemblyName>
Expand All @@ -11,7 +11,6 @@
<PackageProjectUrl>https://github.com/AutoMapper/Automapper.Collection</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/AutoMapper/AutoMapper.Collection/blob/master/LICENSE.txt</PackageLicenseUrl>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.1' ">$(PackageTargetFallback);portable-net45+win8+dnxcore50;portable-net45+win8</PackageTargetFallback>
<Version>3.0.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ public static TDestination Map<TSource, TSourceItem, TDestination, TDestinationI
if (source == null || destination == null)
return destination;

var compareSourceToDestination = source.ToDictionary(s => s, s => destination.FirstOrDefault(d => EquivalencyExpression.IsEquivalent(s, d)));
var destList = destination.ToList();
var compareSourceToDestination = source.ToDictionary(s => s, s =>
{
var match = destList.FirstOrDefault(d => EquivalencyExpression.IsEquivalent(s, d));
destList.Remove(match);
return match;
});

foreach (var removedItem in destination.Except(compareSourceToDestination.Values).ToList())
destination.Remove(removedItem);
Expand Down

0 comments on commit b02ca4f

Please sign in to comment.