I just started using automapper to display DTOs ↔ Entities and it seems to work fine.
In some special cases, I want to display only some properties and perform additional checks. Without automapper, the code looks like this (using quickflect PropertyExtensions):
object target;
object source;
string[] changedPropertyNames = { };
foreach (var changedPropertyName in changedPropertyNames)
{
var newValue = source.GetPropertyValue(changedPropertyName);
target.SetPropertyValue(changedPropertyName, newValue);
}
Of course, this code will not work if type conversion is required. Automapper uses the built-in TypeConverters, and I also created some specific implementations of TypeConverter.
Now I wonder if it is possible to display individual properties and use an implementation of the automapper type conversion, something like this
Mapper.Map(source, target, changedPropertyName);
Update
I think I need more information:
I have already created some maps, for example.
Mapper.CreateMap<CalendarEvent, CalendarEventForm>()
typeconverter nullable dateTime CalendarEvent, .
Mapper.CreateMap<DateTimeOffset?, DateTime?>().ConvertUsing<NullableDateTimeOffsetConverter>();
-api OData Controller. EntityDTOs
Mapper.Map(entityDto, entity);
.
PATCH, a Delta<TDto> entityDto . entityDto.GetChangedPropertyNames() .
, , , a DateTimeOffset? NullableDateTimeOffsetConverter.