Skip to content

Commit f937b0f

Browse files
authored
Merge pull request #4280 from AutoMapper/basic_include
ProjectTo runtime polymorphic mapping with Include/IncludeBase
2 parents 104a192 + 99be09f commit f937b0f

File tree

73 files changed

+5382
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+5382
-367
lines changed

AutoMapper.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMapper.UnitTests", "src
2626
EndProject
2727
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMapper.IntegrationTests", "src\IntegrationTests\AutoMapper.IntegrationTests.csproj", "{24B47F4C-0035-4F29-AAD9-4C47E1AAD98E}"
2828
EndProject
29-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMapper.DI.Tests", "src\AutoMapper.Extensions.Microsoft.DependencyInjection.Tests\AutoMapper.DI.Tests.csproj", "{BEBD620A-8BAA-463F-BE0F-8319AD3C1644}"
29+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoMapper.DI.Tests", "src\AutoMapper.DI.Tests\AutoMapper.DI.Tests.csproj", "{BEBD620A-8BAA-463F-BE0F-8319AD3C1644}"
3030
EndProject
3131
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp", "src\TestApp\TestApp.csproj", "{35CED3AE-B825-4703-992D-A58B5BE646DC}"
3232
EndProject

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ AutoMapper is a simple little library built to solve a deceptively complex probl
1010

1111
This is the main repository for AutoMapper, but there's more:
1212

13-
* [Microsoft DI Extensions](https://github.com/AutoMapper/AutoMapper.Extensions.Microsoft.DependencyInjection)
1413
* [Collection Extensions](https://github.com/AutoMapper/AutoMapper.Collection)
1514
* [Expression Mapping](https://github.com/AutoMapper/AutoMapper.Extensions.ExpressionMapping)
1615
* [EF6 Extensions](https://github.com/AutoMapper/AutoMapper.EF6)

docs/13.0-Upgrade-Guide.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,16 @@ Besides the build-time impact, there is also a behaviour change. Non-generic `Ma
1212

1313
## `AllowAdditiveTypeMapCreation` was removed
1414

15-
Be sure to call `CreateMap` once for a source type, destination type pair. If you want to reuse configuration, use mapping inheritance.
15+
Be sure to call `CreateMap` once for a source type, destination type pair. If you want to reuse configuration, use mapping inheritance.
16+
17+
## ProjectTo runtime polymorphic mapping with Include/IncludeBase
18+
19+
We consider this an off the beaten path feature and we don't expose it through `CreateProjection`. You can use [an extension method](https://github.com/AutoMapper/AutoMapper/search?l=C%23&q=Advanced) or `CreateMap`.
20+
21+
## `Context.State` similar to `Context.Items`
22+
23+
The same pattern the framework uses to pass state to delegates. Note that `State` and `Items` are mutually exclusive per `Map` call.
24+
25+
## Custom Equals/GetHashCode for source objects
26+
27+
To avoid broken implementations, we no longer call those when checking for identical source objects, we hard code to checking object references.

docs/Before-and-after-map-actions.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ var configuration = new MapperConfiguration(cfg => {
4242
});
4343
```
4444

45-
### Asp.Net Core and `AutoMapper.Extensions.Microsoft.DependencyInjection`
46-
If you are using Asp.Net Core and the `AutoMapper.Extensions.Microsoft.DependencyInjection` package, this is also a good way of using Dependency Injection. You can't inject dependencies into `Profile` classes, but you can do it in `IMappingAction` implementations.
45+
### Dependency Injection
46+
You can't inject dependencies into `Profile` classes, but you can do it in `IMappingAction` implementations.
4747

48-
The following example shows how to connect an `IMappingAction` accessing the current `HttpContext` to a `Profile` after map action, leveraging Dependency Injection:
48+
The following example shows how to connect an `IMappingAction` accessing the current `HttpContext` to a `Profile` after map action, leveraging dependency injection:
4949

5050
``` csharp
5151
public class SetTraceIdentifierAction : IMappingAction<SomeModel, SomeOtherModel>
@@ -84,6 +84,4 @@ public class Startup
8484
}
8585
//..
8686
}
87-
```
88-
89-
*See `AutoMapper.Extensions.Microsoft.DependencyInjection` for more info.*
87+
```

docs/Custom-value-resolvers.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ This is how to setup the mapping for this custom resolver
127127
cfg.CreateMap<Source, Dest>()
128128
.ForMember(dest => dest.Foo, opt => opt.MapFrom((src, dest, destMember, context) => context.Items["Foo"]));
129129
```
130+
Starting with version 13.0, you can use `context.State` instead, in a similar way. Note that `State` and `Items` are mutually exclusive per `Map` call.
130131

131132
### ForPath
132133

docs/Queryable-Extensions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ Not all mapping options can be supported, as the expression generated must be in
227227
* NullSubstitute
228228
* Value transformers
229229
* IncludeMembers
230+
* Runtime polymorphic mapping with Include/IncludeBase
230231

231232
Not supported:
232233
* Condition
@@ -237,6 +238,5 @@ Not supported:
237238
* Custom resolvers
238239
* Custom type converters
239240
* ForPath
240-
* Value converters
241-
* Runtime polymorphic mapping with Include/IncludeBase
241+
* Value converters
242242
* **Any calculated property on your domain object**

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ New to AutoMapper? Check out the :doc:`Getting-started` page first.
6868
:caption: Upgrading
6969

7070
API-Changes
71+
13.0-Upgrade-Guide
7172
12.0-Upgrade-Guide
7273
11.0-Upgrade-Guide
7374
10.0-Upgrade-Guide

0 commit comments

Comments
 (0)