Hello everyone,
I got the following error while trying to map my domain classes to dto’s using Automapper on a mongoDbQueryable.
Expression not supported: Convert(EnumA, EnumB) because conversion to EnumB is not supported.",
I use EnumRepresentationConvention(BsonType.String)
Does anyone know, how to correctly map enums using the LINQ 3 translator?
Reproduce Steps:
public class Foo(
Guid id,
Bar bar);
public enum Bar
{
A,
B,
}
public class FooDto(
Guid id,
BarDto bar);
public enum BarDto
{
A,
B,
}
public class MappingProfile : Profile
{
public MappingProfile()
{
CreateMap<Foo, FooDto>();
CreateMap<Bar, BarDto>().ConvertUsing(src => (BarDto)src); // Also tried Enum.Parse
}
}
var queryable = repo.GetAll();
var dtoQueryable = queryable.ProjectTo<AngebotDto>(_mapper.ConfigurationProvider)