MagicMapper.Collection 0.0.0-alpha.0.117

This is a prerelease version of MagicMapper.Collection.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MagicMapper.Collection --version 0.0.0-alpha.0.117
                    
NuGet\Install-Package MagicMapper.Collection -Version 0.0.0-alpha.0.117
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MagicMapper.Collection" Version="0.0.0-alpha.0.117" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MagicMapper.Collection" Version="0.0.0-alpha.0.117" />
                    
Directory.Packages.props
<PackageReference Include="MagicMapper.Collection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MagicMapper.Collection --version 0.0.0-alpha.0.117
                    
#r "nuget: MagicMapper.Collection, 0.0.0-alpha.0.117"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MagicMapper.Collection@0.0.0-alpha.0.117
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MagicMapper.Collection&version=0.0.0-alpha.0.117&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MagicMapper.Collection&version=0.0.0-alpha.0.117&prerelease
                    
Install as a Cake Tool

MagicMapper.Collection

NuGet

Adds collection mapping support to MagicMapper. Maps collections to existing collections without recreating the collection object — items are added, updated, or removed based on a user-defined equivalency expression.

Based on AutoMapper.Collection.

Installation

dotnet add package MagicMapper.Collection

Setup

Call AddCollectionMappers() when configuring your mapper:

var config = new MapperConfiguration(cfg =>
{
    cfg.AddCollectionMappers();
    cfg.CreateMap<OrderItemDto, OrderItem>()
       .EqualityComparison((dto, item) => dto.Id == item.Id);
});

IMapper mapper = config.CreateMapper();

How it works

Given a source and destination collection, MagicMapper.Collection compares items using the equivalency expression you define:

  • Matching items — maps the source item onto the existing destination item (update)
  • Source item with no match — adds a new destination item to the collection
  • Destination item with no match in source — removes it from the collection
// orders.Items is an existing collection — it is updated in-place
mapper.Map(orderDto, order);

This is particularly useful with ORMs, which track collection identity and do not respond well to replacing the entire collection object.

Defining equivalency

cfg.CreateMap<OrderItemDto, OrderItem>()
   .EqualityComparison((dto, item) => dto.Id == item.Id);

License

MIT

AutoMapper is Copyright © 2009 Jimmy Bogard and other contributors under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 40 6/13/2026
0.0.0-alpha.0.117 37 6/13/2026
0.0.0-alpha.0.116 37 6/11/2026
0.0.0-alpha.0.115 45 6/11/2026