I am trying to map from Vehicle object to the Motor object using Automapper
public class Range<T>
{
public T Min { get; set; }
public T Max { get; set; }
}
public Enum SpeedType
{
[Display(Name = "-")] Unknown = 0,
[Display(Name = "M")] Manual= 1,
[Display(Name = "A")] Automatic= 2
}
public class Vehicle
{
public Range<string> Speed { get; set; }
}
public class Motor
{
public Range<SpeedType?> Speed { get; set; }
}
I have tried using the MapFrom (reading the documentation) without any success. Can someone point me in the right direction. I am not even sure if this can be even mapped using Automapper. I have used automapper in the past for simple mappings.
Range<T>with an Enum as you've set it doesn't make sense. Why is Automatic max and Manual min or the other way around, There is no concept in the real world of one being greater than the other.AutoMapper. I had to use it in a project for more than a year but actually it is only good for making simple things more complicated than necessary. SomeFromDtoandToDto[extension] methods are just simpler, faster, easier to debug and more reactive to code changes. Mapping between different class layouts often results practically as much code (or even more with tons of lambdas) as simply writing the mapping manually. See also: cezarypiatek.github.io/post/why-i-dont-use-automapper