Query/Test: temporal table query infra doesn't work when using Set of entity that is not root inside lambda
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Specifically, when we need to project a collection of owned entity types that are not root.
e.g.:
```cs
ss => ss.Set()
.Select(l1 => ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l2.Id)))
```
for temporal table testing we inject TemporalAsOf calls, so the rewriter creates something like this:
```cs
DbSet().TemporalAsOf(1/1/2010 12:00:00 AM)
.Select(l1 => ((DbSet)ss.Set())
.TemporalAsOf(1/1/2010 12:00:00 AM)
.Include(l2 => l2.OneToMany_Optional2
.Where(x => x.Id != l2.Id)))
```
However, when we try to evaluate the subquery in the projection the ss.Set() is expanded to `Set().Select(t => t.OneToOne_Required_PK1).Where(t => t != null)`, which is IQueryable, so the valuation fails.
To fix it we need a different SetExtractor for temporal and also adjust server query rewriter to not try to inject TemporalAsOf into the expressions as we would (presumably) have already injected them in the SetExtractor
Contributor guide
Assessment
This issue has not been assessed yet.