Version Used:
.NET Core 3.1 with Microsoft.EntityFrameworkCore 3.1.1, nullable reference types enabled.
Steps to Reproduce:
using System.Linq;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Query;
namespace TestApplication
{
public static class Test
{
public static void Run()
{
IQueryable<A> query = new A[0].AsQueryable();
IIncludableQueryable<A, C?> result = query.Include(a => a.NavProperty).ThenInclude(b => b.NavProperty);
}
}
public sealed class A
{
public B? NavProperty { get; set; }
}
public sealed class B
{
public C? NavProperty { get; set; }
}
public sealed class C
{
}
}
This code will result in a Dereference of a possibly null reference warning on the b => b.NavProperty expression. This means ThenInclude requires either suppressing this warning globally (which takes away the useful occurrences of the warning), suppressing it locally (which will turn the code into a mess) or living with way too many warnings in an otherwise warning free solution (not workable). The null conditional operator that would be used in regular code is not available in expressions.
Expected Behavior:
No warning or
A way to disable the warning only for expressions or
A way (attribute) for ThenInclude to signal it's not going to compile the expression.
Actual Behavior:
Dereference of a possibly null reference warning.
Version Used: .NET Core 3.1 with Microsoft.EntityFrameworkCore 3.1.1, nullable reference types enabled.
Steps to Reproduce:
This code will result in a Dereference of a possibly null reference warning on the
b => b.NavProperty
expression. This means ThenInclude requires either suppressing this warning globally (which takes away the useful occurrences of the warning), suppressing it locally (which will turn the code into a mess) or living with way too many warnings in an otherwise warning free solution (not workable). The null conditional operator that would be used in regular code is not available in expressions.Expected Behavior:
Actual Behavior: Dereference of a possibly null reference warning.