Closed
Description
I have this Config
public void Register(TypeAdapterConfig config)
{
config
.NewConfig<Domain.Entity.News.News, SitemapNode>()
.AddDestinationTransform((string x) => x.Trim())
.Map(dest => dest.Url, src => GetNewsUrl(src.Id,src.Title))
.Map(dest => dest.LastModified, src => src.ModifiedDate == null ? src.CreatedDate:src.ModifiedDate.Value)
;
}
private string GetNewsUrl(long ID, string TItle)
{
var HttpContextAccessor = MapContext.Current.GetService<IHttpContextAccessor>();
return "Fine";
}
when I want to run the below code I got exception :
await
_Context
.Set<Domain.Entity.News.News>()
.AsNoTracking()
.ProjectToType<SitemapNode>(_mapper.Config)
.ToListAsync(cancellationToken)
.ConfigureAwait(false);
InvalidOperationException: Mapping must be called using ServiceAdapter
Metadata
Metadata
Assignees
Labels
No labels