Mapping must be called using ServiceAdapter

See original GitHub issue

when I want to use MapContext.Current.GetService<IMyService>() in my mapping I get the error Mapping must be called using ServiceAdapter ?


public class RegisteredCharityConfig : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config
                .NewConfig<CharityAccount,RegisteredCharityDto>()
                .PreserveReference(true)
                .AddDestinationTransform((string x) => x.Trim())
                .Map(dest => dest.ImageUrl, src => MapContext.Current.GetService<IUrlUtility>().GetUrlDirectoryMinified(DirectoryKind.Charity, src.Id) )
                ;
         }
    }

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
chaowlertcommented, Feb 13, 2020

Can linq.ProjectToType<Dto>(mapper.Config)

0reactions
sonsy-softcommented, Mar 20, 2020

Hi chaowlert I get the same error after calling the scan method in code. here is my Code

            var Config = GetConfiguration();
            Services.AddSingleton(Config);
            Services.AddScoped<IMapper, ServiceMapper>();
            Config.Scan(assemblies);

more informatino i use autofac for DI in .net core 3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Mapster w/DI where should I be putting my mapping?
Config in the Startup.ConfigureServices method Iget an error "Mapping must be called using ServiceAdapter". Not sure how/where that would be ...
Read more >
Mapster
I'm using ProjectToType to generate mapping expressions for both SQL Server projects and a MongoDB project: ... Mapping must be called using ServiceAdapter....
Read more >
InvalidOperationException when using DI in collection ...
System.InvalidOperationException : Mapping must be called using ServiceAdapter at Mapster.TypeAdapterExtensions.GetService[TService](MapContext ...
Read more >
Creating a Service Adapter using On-Demand Services SDK
Your service adapter must provide the following: The mapping of instance groups to jobs for the deployment. Job level properties for the ...
Read more >
AutoMapper Madness - Unit Testing Your Maps - Blog
AutoMapper will throw an AutoMapperMappingException with the message that begins with “Missing type map configuration or unsupported mapping.” ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found