title: Why Automapper needs IMapper interface for map?
body: <p>I have created an extension to map my types that implemented <code>IHaveStandardMapping</code> interface.</p>
  
  <pre><code>public static class AutomapperExtensions
  {
      public static TDest MapTo&lt;TDest&gt;(this object src, IMapper mapper) 
          where TDest: IHaveStandardMapping
      {
          return (TDest)mapper.Map(src, src.GetType(), typeof(TDest));
      }
  }
  </code></pre>
  
  <p>And I am using it in my service.</p>
  
  <pre><code>public class ComponentService : IComponentService
  {
      private readonly PostgresqlDataContext _context;
      private readonly IMapper _mapper;
  
      public ComponentService(PostgresqlDataContext context, IMapper mapper)
      {
          _context = context;
          _mapper = mapper;
      }
  
      public async Task&lt;ComponentViewModel&gt; GetComponent(string id)
      {
          var existing = await _context.Components.FirstOrDefaultAsync(s =&gt; s.Id == id);
  
          if (existing == null)
              throw new EntityNotFoundException("Component");
  
          var result = existing.MapTo&lt;ComponentViewModel&gt;(_mapper);
  
          return result;
      }
  }
  </code></pre>
  
  <p>But I need to get <code>IMapper</code> interface for all services. </p>
  
  <p>I should use it in method </p>
  
  <pre><code>existing.MapTo&lt;T&gt;(_mapper); 
  </code></pre>
  
  <p>The old versions were did not need the <code>IMapper</code> interface. </p>
  
  <p>Is there a short way without using <code>IMapper</code>?</p>