4

I have been trying to create a automapper Custom value resolvers, but I seem to have missed some set up step as it can never seem to find

 public abstract class ValueResolver<TSource, TDestination> : IValueResolver

So in the following snippet will not compile.

using DITest.Models; // This is where the SalesOrder class is
using AutoMapper;

namespace DITest.AutoMapper.SaleOrder
{
  public class FullAddress : ValueResolver<SalesOrder, string>
  {
    protected override string ResolveCore(SalesOrder source)
    {
        return "foo bar"; 
    }
  }
}

I get the error message

The type or namespace name 'ValueResolver<,>' could not be found (are you missing a using directive or an assembly reference?)

Its say the using AutoMapper is not used.

In the past I have been naughty and hacked in a reference for lib\net45\AutoMapper.dll

1
  • Hi there, did you ever find a solution to this issue?
    – sim1
    Commented May 4, 2017 at 10:55

2 Answers 2

2

Please try IMemberValueResolver type instead of IValueResolver. The AutoMapper had some upgraded things.

https://github.com/AutoMapper/AutoMapper/wiki/5.0-Upgrade-Guide

1

ValueResolver is gone. IValueResolver is the replacement. And there is also IMemberValueResolver, as the docs say.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.