SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top