I have two simple DTO defined that I'm passing to automapper v10.0.0
class RequestDTO {
public int Id { get; set; }
// other properties
public IEnumerable<AssetDTO> Assets { get; set; }
}
class AssetDTO {
public int RequestId { get; set; }
// other properties
}
When I map an asset, it should show the RequestId
. That's working fine. However, when I map a RequestDTO
, there's no reason for each asset to include the RequestId
as the Id
is already included via the RequestDTO
.
Is there a simple way to ignore the RequestId
when it's being mapped as a result of the parent request being mapped?
So if I'm just mapping an asset, I want
{
"RequestId": 12,
"OtherProperty": ""
}
but if I'm mapping a request, I want:
{
"Id": 12,
"Assets": [
{
"OtherProperty", ""
}
]
}