Code: Select all
public class BeastRider
{
public long Id { get; private set; }
public string RiderName { get; private set; }
public Beast? Beast { get; private set; }
}
Code: Select all
modelBuilder.Entity<BeastRider>().OwnsOne(_ => _.Beast,
ba =>
{
ba.Property(beast => beast.Name).HasColumnName("BEAST_NAME");
});
Code: Select all
// This works
var khalDrogo = await context.Set<BeastRider>()
.FirstOrDefaultAsync(_ => _.Beast != null && _.Beast.Name == "Khal drogo");
// This fails with 'System.InvalidOperationException: Null TypeMapping in Sql Tree'
var khals = await context.Set<BeastRider>()
.Where(_ => _.Beast != null && _.Beast.Name.StartsWith("Khal"))
.ToArrayAsync();
A repository reproducing the bug can be found here.
Reproducible for:
- Devart.Data.Oracle.EFCore: 9.9.887
- Microsoft.EntityFrameworkCore.Relational: 3.0.1 & 3.1.0
- .NET Core SDK versions: 3.0.101 & 3.1.100
- .NET Core Runtime versions: 3.0 & 3.1
Code: Select all
SELECT "b".ID,
"b".RIDER_NAME,
"t".ID ID1,
"t".BEAST_NAME
FROM BEAST_RIDER "b"
LEFT JOIN
(SELECT "b0".ID, "b0".BEAST_NAME, "b1".ID ID0
FROM BEAST_RIDER "b0"
INNER JOIN BEAST_RIDER "b1" ON "b0".ID = "b1".ID
WHERE "b0".BEAST_NAME IS NOT NULL) "t"
ON "b".ID = "t".ID
WHERE "t".ID IS NOT NULL AND ("t".BEAST_NAME = 'Khal drogo')
FETCH FIRST 1 ROWS ONLY