dotnet / dotnet/efcore

Allow a TemporalAll and other temporal range queries to Include the current rows from non-temporal tables

Open
#27,237 21 comments 45 reactions 0 assignees View on GitHub
area-query area-temporal-tables customer-reported needs-design
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

## File a bug

The same as https://github.com/dotnet/efcore/issues/26704. I undersand reasoning in https://github.com/dotnet/efcore/issues/26704 but it should work when used with `.Select(x => new { ... })` or `.AsNoTracking()`. The whole feature is pretty much useless if we can't query anything but one table. Even hack we use today
```
var query = Set().ProjectTo();
sql = query.ToQueryString();
sql = sql.Replace($"[{table}]", $"[{table}] FOR SYSTEM_TIME ALL");
var rows = Set().FromSqlRaw(sql).ToList();
```
is way better than the official implementation.

### Include your code

```C#
context.Set().TemporalAll().Select(x => new { x.A, x.B.C }).ToList();
```

### Include stack traces

```
Unhandled exception. System.InvalidOperationException: Temporal query is trying to use navigation to an entity 'XXX' which itself doesn't map to temporal table. Either map the entity to temporal table or use join manually to access it.
```

### Include provider and version information

EF Core version: 6.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Debian 11

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.