Quick error fix for anyone experiencing the same issue, looks like the syntax for ResolveUsing has changed as of 3.2.0.
Just updated Automapper on my project to 3.2.1. And getting the following error.
The call is ambiguous between the following methods or properties ‘AutoMapper.IMemberConfigurationExpression.ResolveUsing(System.Func
)’ and ‘AutoMapper.IMemberConfigurationExpression.ResolveUsing(System.Func )’
Mapper.CreateMap<TaskCreated, Task>()
.ForMember(x => x.Created, x => x.ResolveUsing(t => DateTime.UtcNow))
.ForMember(x => x.Modified, x => x.ResolveUsing(t => DateTime.UtcNow))
.ForMember(x => x.Deleted, x => x.Ignore());
A quick search sees other people with the same issue
https://github.com/AutoMapper/AutoMapper/issues/497
So there is 2 options.
- Use MapFrom
Mapper.CreateMap<TaskCreated, Task>()
.ForMember(x => x.Created, x => x.MapFrom(t => DateTime.UtcNow))
.ForMember(x => x.Modified, x => x.MapFrom(t => DateTime.UtcNow))
.ForMember(x => x.Deleted, x => x.Ignore());
- Explicitly tell Automapper what object I’m using in the lambda.
Mapper.CreateMap<TaskCreated, Task>()
.ForMember(x => x.Created, x => x.ResolveUsing((TaskCreated t) => DateTime.UtcNow))
.ForMember(x => x.Modified, x => x.ResolveUsing((TaskCreated t) => DateTime.UtcNow))
.ForMember(x => x.Deleted, x => x.Ignore());