Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94296ab
only consider explicitly included maps
lbargaoanu Oct 8, 2022
7b46628
That means that you don't need to use explicit eager loading (`Includ…
lbargaoanu Oct 9, 2022
317d2d7
`Include`/`IncludeBase` applies recursively, so you only need to incl…
lbargaoanu Oct 9, 2022
4928013
cosmetic
lbargaoanu Oct 13, 2022
7b5ab5d
validate constructors for generic maps
lbargaoanu Oct 14, 2022
be8fa7b
<MinVerDefaultPreReleasePhase>preview
lbargaoanu Oct 14, 2022
944e64b
move the source null check to the beginning of the execution plan
lbargaoanu Oct 15, 2022
eadc60c
cosmetic
lbargaoanu Oct 15, 2022
9a488ee
Runtime polymorphic mapping doesn't work with ProjectTo
lbargaoanu Oct 26, 2022
a019497
cancel-in-progress: true
lbargaoanu Oct 26, 2022
402651e
cosmetic
lbargaoanu Nov 5, 2022
54fe257
allow explicit expansion for constructors
lbargaoanu Nov 11, 2022
a2e8a2b
ReverseMap and As
lbargaoanu Nov 14, 2022
4630d56
don't validate property maps mapped through constructors
lbargaoanu Nov 14, 2022
3bbebac
windows-latest
lbargaoanu Nov 19, 2022
5d148e6
When mapping to records, consider only using public constructors.
lbargaoanu Nov 24, 2022
a7bca7c
run on .Net 7
lbargaoanu Nov 25, 2022
5e71e3e
readonly members can in fact be mapped
lbargaoanu Nov 26, 2022
ea49c46
NullToExistingDestination
lbargaoanu Dec 7, 2022
1f276d9
file scoped namespace
lbargaoanu Dec 17, 2022
a861cf3
ResolutionContext.TryGetItems
lbargaoanu Dec 17, 2022
1f6c603
more efficient
lbargaoanu Dec 21, 2022
805e21f
cosmetic
lbargaoanu Dec 26, 2022
a726f09
we cannot reverse open generics with ForPath because ForPath doesn't …
lbargaoanu Jan 2, 2023
8872c72
type converter maps don't need extra configuration
lbargaoanu Jan 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ on:
- master
permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
fail-fast: false
runs-on: windows-2022
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
strategy:
fail-fast: false
runs-on: windows-2022
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ project.lock.json
# Read the Docs
docs/_build
/src/LastMajorVersionBinary
*.diagsession
4 changes: 2 additions & 2 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ function Exec
}
}

$artifacts = ".\artifacts"
$artifacts = "..\artifacts"

if(Test-Path $artifacts) { Remove-Item $artifacts -Force -Recurse }

exec { & dotnet clean -c Release }

exec { & dotnet build -c Release }

exec { & dotnet test -c Release -r $artifacts --no-build -l trx --verbosity=normal }
exec { & dotnet test -c Release --results-directory $artifacts --no-build -l trx --verbosity=normal }

exec { & dotnet pack .\src\AutoMapper\AutoMapper.csproj -c Release -o $artifacts --no-build }

2 changes: 1 addition & 1 deletion Push.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$scriptName = $MyInvocation.MyCommand.Name
$artifacts = "./artifacts"
$artifacts = "../artifacts"

if ([string]::IsNullOrEmpty($Env:NUGET_API_KEY)) {
Write-Host "${scriptName}: NUGET_API_KEY is empty or not set. Skipped pushing package(s)."
Expand Down
2 changes: 1 addition & 1 deletion docs/12.0-Upgrade-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Another possible occurence is with `ForAllMaps` and `ForAllPropertyMaps` when it

## `ResolutionContext.Options` was removed

You should use `ResolutionContext.Items` to access the items passed in the `Map` call.
You should use `ResolutionContext.Items` to access the items passed in the `Map` call. Starting with version 12.0.1, you can use `TryGetItems` if you want to check whether a context was passed in the `Map` call.

Instead of `ServiceCtor`, you should use dependency injection or pass the needed objects in the `Map` call.

Expand Down
3 changes: 2 additions & 1 deletion docs/Construction.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ You can configure which constructors are considered for the destination object:
```c#
// use only public constructors
var configuration = new MapperConfiguration(cfg => cfg.ShouldUseConstructor = constructor => constructor.IsPublic);
```
```
When mapping to records, consider using only public constructors.
7 changes: 5 additions & 2 deletions docs/Mapping-inheritance.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ CreateMap<DerivedEntity, DerivedDto>()
.IncludeBase<BaseEntity, BaseDto>();
```

In each case above, the derived mapping inherits the custom mapping configuration from the base mapping configuration.
In each case above, the derived mapping inherits the custom mapping configuration from the base map.

To include all derived maps, from the base type map configuration:
`Include`/`IncludeBase` applies recursively, so you only need to include the closest level in the hierarchy.

If for some base class you have many directly derived classes, as a convenience, you can include all derived maps from the base type map configuration:

```c#
CreateMap<BaseEntity, BaseDto>()
.IncludeAllDerived();

CreateMap<DerivedEntity, DerivedDto>();
```
Note that this will search all your mappings for derived types and it will be slower than explicitly specifying the derived maps.

### Runtime polymorphism

Expand Down
18 changes: 12 additions & 6 deletions docs/Queryable-Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@ select new InstructorIndexData.InstructorModel
};
```

This map through AutoMapper will result in a SELECT N+1 problem, as each child `Course` will be queried one at a time, unless specified through your ORM to eagerly fetch. With LINQ projection, no special configuration or specification is needed with your ORM. The ORM uses the LINQ projection to build the exact SQL query needed.

This map through AutoMapper will result in a SELECT N+1 problem, as each child `Course` will be queried one at a time, unless specified through your ORM to eagerly fetch. With LINQ projection, no special configuration or specification is needed with your ORM. The ORM uses the LINQ projection to build the exact SQL query needed.

That means that you don't need to use explicit eager loading (`Include`) with `ProjectTo`. If you need something like filtered `Include`, have the filter in your map:

```c#

CreateProjection<Entity, Dto>().ForMember(d => d.Collection, o => o.MapFrom(s => s.Collection.Where(i => ...));
```

### Custom projection

In the case where members names don't line up, or you want to create calculated property, you can use MapFrom (the expression-based overload) to supply a custom expression for a destination member:
Expand Down Expand Up @@ -220,7 +227,6 @@ Not supported:
* Custom resolvers
* Custom type converters
* ForPath
* Value converters
* **Any calculated property on your domain object**

Additionally, recursive or self-referencing destination types are not supported as LINQ providers do not support this. Typically hierarchical relational data models require common table expressions (CTEs) to correctly resolve a recursive join.
* Value converters
* Runtime polymorphic mapping with Include/IncludeBase
* **Any calculated property on your domain object**
Loading