Guest User

Untitled

a guest
May 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. internal class DepartamentStructService : IDepartamentStructService
  2. {
  3. private IUnitOfWork Database { get; set; }
  4.  
  5. private IAutoMapper AutoMapper { get; set; }
  6.  
  7. public DepartamentStructService(IUnitOfWork database, IAutoMapper autoMapper)
  8. {
  9. Database = database;
  10. AutoMapper = autoMapper;
  11. }
  12.  
  13. public IEnumerable<DepartamentStructDto> GetDepartamentStructAll() => AutoMapper.Projection<IEnumerable<DEPARTMENTSTRUCT>, IEnumerable<DepartamentStructDto>>(Database.DepartamentsStruct.GetAll());
  14.  
  15. public void Dispose() => Database.Dispose();
  16. }
  17.  
  18. internal class AutoMapperCollection : IAutoMapper
  19. {
  20. public TDestination Projection<TSource, TDestination>(TSource source)
  21. where TSource : class
  22. where TDestination : class
  23. {
  24. var mapper = new MapperConfiguration(cfg => cfg.CreateMap<TSource, TDestination>()).CreateMapper();
  25. return mapper.Map<TSource, TDestination>(source);
  26. }
  27. }
Add Comment
Please, Sign In to add comment