Is your feature request related to a problem? Please describe.
When using EF Core IQueryable mapping projections, sometimes user-defined mapping methods can not be inlined which causes EF Core to skip generating SQL queries for query projection but instead loads all columns and all related entities and executes the projection client-side.
Describe the solution you'd like
When user-defined mapping methods can not be inlined into IQueryable-projections, a compile warning (which can be treated as error) prevents unintentional client-side evaluations.
[Mapper]
public static partial class PersonDtoMapper
{
private static string MapFullName(PersonDbo src)
{
// this renaming prevents inlining
var source = src;
return source.FirstName + " " + source.LastName;
}
// Expected a compile warning here that MapFullName could not be inlined to MapToPersonDto() expression
[MapPropertyFromSource(nameof(UserDto.FullName), Use = nameof(MapFullName))]
private static partial PersonDto MapToPersonDto(PersonDbo src);
public static partial Expression<Func<PersonDbo, PersonDto>> MapToPersonDto();
}
Describe alternatives you've considered
Always inspect generated projection after any changes.
Additional context
Is your feature request related to a problem? Please describe.
When using EF Core
IQueryablemapping projections, sometimes user-defined mapping methods can not be inlined which causes EF Core to skip generating SQL queries for query projection but instead loads all columns and all related entities and executes the projection client-side.Describe the solution you'd like
When user-defined mapping methods can not be inlined into
IQueryable-projections, a compile warning (which can be treated as error) prevents unintentional client-side evaluations.Describe alternatives you've considered
Always inspect generated projection after any changes.
Additional context