Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. namespace AspNetCoreTemplate.Services.Mapping
  2. {
  3. using System;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6.  
  7. using AutoMapper.QueryableExtensions;
  8.  
  9. public static class QueryableMappingExtensions
  10. {
  11. public static IQueryable<TDestination> To<TDestination>(
  12. this IQueryable source,
  13. params Expression<Func<TDestination, object>>[] membersToExpand)
  14. {
  15. if (source == null)
  16. {
  17. throw new ArgumentNullException(nameof(source));
  18. }
  19.  
  20. return source.ProjectTo(AutoMapperConfig.MapperInstance.ConfigurationProvider, null, membersToExpand);
  21. }
  22.  
  23. public static IQueryable<TDestination> To<TDestination>(
  24. this IQueryable source,
  25. object parameters)
  26. {
  27. if (source == null)
  28. {
  29. throw new ArgumentNullException(nameof(source));
  30. }
  31.  
  32. return source.ProjectTo<TDestination>(AutoMapperConfig.MapperInstance.ConfigurationProvider, parameters);
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement