dotnet / dotnet/efcore

Don't generate unneeded subquery in TPC with OfType

Open
#28,214 2 comments 1 reaction 0 assignees View on GitHub
area-query
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Query:

```C#
var results3 = context.Animals.OfType().Where(a => a.Species.StartsWith("F")).ToList();
```

SQL:

```sql
SELECT [t].[Id], [t].[Species], [t].[Name], [t].[EducationLevel], [t].[Discriminator]
FROM (
SELECT [c].[Id], [c].[Species], [c].[Name], [c].[EducationLevel], N'Cat' AS [Discriminator]
FROM [Cats] AS [c]
) AS [t]
WHERE [t].[Species] LIKE N'F%'
```

The extra subquery here isn't needed and can be removed.

Split off from #28199

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.