Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class DepartamentStructService : IDepartamentStructService
- {
- private IUnitOfWork Database { get; set; }
- private IAutoMapper AutoMapper { get; set; }
- public DepartamentStructService(IUnitOfWork database, IAutoMapper autoMapper)
- {
- Database = database;
- AutoMapper = autoMapper;
- }
- public IEnumerable<DepartamentStructDto> GetDepartamentStructAll() => AutoMapper.Projection<IEnumerable<DEPARTMENTSTRUCT>, IEnumerable<DepartamentStructDto>>(Database.DepartamentsStruct.GetAll());
- public void Dispose() => Database.Dispose();
- }
- internal class AutoMapperCollection : IAutoMapper
- {
- public TDestination Projection<TSource, TDestination>(TSource source)
- where TSource : class
- where TDestination : class
- {
- var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TSource, TDestination>()).CreateMapper();
- return mapper.Map<TSource, TDestination>(source);
- }
- }
Add Comment
Please, Sign In to add comment