Skip to content

Commit

Permalink
fix MapsterMapper#260 non generic ProjectToType
Browse files Browse the repository at this point in the history
  • Loading branch information
chaowlert committed Aug 19, 2020
1 parent 9e96dd4 commit e3872a1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Mapster/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public static IQueryable<TDestination> ProjectToType<TDestination>(this IQueryab
return source.Provider.CreateQuery<TDestination>(sourceCall);
}

public static IQueryable ProjectToType(this IQueryable source, Type destinationType, TypeAdapterConfig? config = null)
{
config ??= TypeAdapterConfig.GlobalSettings;
var mockCall = config.GetProjectionCallExpression(source.ElementType, destinationType);
var sourceCall = Expression.Call(mockCall.Method, source.Expression, mockCall.Arguments[1]);
return source.Provider.CreateQuery(sourceCall);
}

public static bool HasCustomAttribute(this IMemberModel member, Type type)
{
return member.GetCustomAttributes(true).Any(attr => attr.GetType() == type);
Expand Down

0 comments on commit e3872a1

Please sign in to comment.