MagicMapper.Collection
0.0.0-alpha.0.116
See the version list below for details.
dotnet add package MagicMapper.Collection --version 0.0.0-alpha.0.116
NuGet\Install-Package MagicMapper.Collection -Version 0.0.0-alpha.0.116
<PackageReference Include="MagicMapper.Collection" Version="0.0.0-alpha.0.116" />
<PackageVersion Include="MagicMapper.Collection" Version="0.0.0-alpha.0.116" />
<PackageReference Include="MagicMapper.Collection" />
paket add MagicMapper.Collection --version 0.0.0-alpha.0.116
#r "nuget: MagicMapper.Collection, 0.0.0-alpha.0.116"
#:package MagicMapper.Collection@0.0.0-alpha.0.116
#addin nuget:?package=MagicMapper.Collection&version=0.0.0-alpha.0.116&prerelease
#tool nuget:?package=MagicMapper.Collection&version=0.0.0-alpha.0.116&prerelease
MagicMapper.Collection
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
| Product | Versions 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. |
-
net10.0
- MagicMapper (>= 14.0.1)
-
net8.0
- MagicMapper (>= 14.0.1)
-
net9.0
- MagicMapper (>= 14.0.1)
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 |