Skip to content

Null reference when calling Trim() on interpolated string containing null property #2860

Closed
@G1Vh

Description

@G1Vh

Linq query worked in 5.3.8 but fails in 5.3.9 with null reference exception.

We have code like this:

var employees = await employeeRepository.Query()
                                                    .Select(c => new Employee
                                                     {
                                                         Id = c.Id,
                                                         Name = $"{c.Name} {c.Surname}".Trim()
                                                     })
                                                    .ToListAsync();

One of employees has null in Surname property.
If Trim() removed query works in 5.3.9.

Generated sql is same in both versions:

    select
        employee0_.id as col_0_0_,
        ?p0 as col_1_0_,
        employee0_.name as col_2_0_,
        employee0_.surname as col_3_0_
    from
        employee employee0_;
    ?p0 = '{0} {1}' [Type: String (7:0:0)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions