想在automapper转换实体的时候获取缓存数据。
using AutoMapper;
public class TestProfile : Profile
{
public TestProfile()
{
IServiceProvider serviceProvider = new ServiceCollection().BuildServiceProvider();
IMemoryCache _cache = serviceProvider.GetService<IMemoryCache>();
}
}
无法获取到_cache
using AutoMapper;
public class TestProfile : Profile
{
public TestProfile(IMemoryCache _cache)
{
}
}
TestProfile构造函数报错
相关问题
- How to ignore properties of a specific type when u
- EF Core - Return mapped Many-to-Many relationship
- Validation of nested models in view model in ASP.N
- Using string.Split() in AutoMapper issue
- Mapping from two items with automapper
建议远离这样的反模式