Skip to content

Commit a2b428c

Browse files
committed
Updating code example
1 parent fb7d823 commit a2b428c

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

_posts/2020-06-18-agilemapper-v1_7.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,19 @@ by the mapper whenever the configured type pair is matched:
2222
```csharp
2323
Mapper.WhenMapping
2424
.From<Address>().To<AddressDto>()
25-
.MapInstancesUsing((a, dto) => new AddressDto
25+
.MapInstancesUsing(ctx => new AddressDto
2626
{
27-
Number = a.HouseNo,
28-
Line1 = a.Street,
29-
Line2 = a.Town,
30-
Line3 = a.City,
31-
Line4 = a.County,
32-
Postcode = a.PostalCode
27+
Number = ctx.Source.HouseNo,
28+
Line1 = ctx.Source.Street,
29+
Line2 = ctx.Source.Town,
30+
Line3 = ctx.Source.City,
31+
Line4 = ctx.Source.County,
32+
Postcode = ctx.Source.PostalCode
3333
});
3434
```
3535

36+
See a live example on [DotNetFiddle](https://dotnetfiddle.net/XNPrMS){:target="_blank"}.
37+
3638
## Alternate Data Sources
3739

3840
To map from a data source other than a source model's matching member, an alternate source can be

0 commit comments

Comments
 (0)