Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3390956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:45:02+00:00 2026-05-18T03:45:02+00:00

Hi I am using AutoMapper to move from a Model to a Dto and

  • 0

Hi I am using AutoMapper to move from a Model to a Dto and it’s working great.
In one TypeConverter I need to inject an Interface (a service) that has to be used by the type converter in order to do the conversion.

How can I accomplish this in AutoMapper?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:45:03+00:00Added an answer on May 18, 2026 at 3:45 am

    Can you not just create a constructor on your TypeConverter class, accepting the service? Rather than using the generic ConvertUsing, pass in a new instance of your TypeConverter constructed with the service…

        public class MyTypeConverter : TypeConverter<String, String>
        {
            public MyTypeConverter(IMyService service)
            {
                MyService = service;
            }
    
            public IMyService MyService { get; set; }
    
            protected override string  ConvertCore(string source)
            {
                //use service
            }
         }
    

    Usage:

         Mapper.CreateMap<string, string>()
                         .ConvertUsing(new MyTypeConverter(_myService));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using AutoMapper.org to map my DTO objects to Model objects in MVC4.
I am using automapper to import from one DB into a new DB with
I'm using AutoMapper which is a great tool. There's lots of examples converting from
I am using AutoMapper to datareader using code as discussed below http://elegantcode.com/2009/10/16/mapping-from-idatareaderidatarecord-with-automapper/ I see
Any idea how I can tell AutoMapper to resolve a TypeConverter constructor argument using
There are lots of tutorials for flattening domain models into DTO using AutoMapper. I
I am using AutoMapper to map objects from a legacy database to a new
I have this interface for using AutoMapper: public interface IMapper { object Map(object source,
I'm having a really difficult time mapping from a DynamicObject using Automapper -- the
I'm using AutoMapper in an ASP.NET MVC application. I was told that I should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.