Skip to content

elevate default severity of RMG068 from info to warning (queryable projection's user implemented mapping not inlinable) #2250

@mhartmair-cubido

Description

@mhartmair-cubido

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeThis issue or pull request will break existing consumersenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions