dotnet / dotnet/fsharp

[Query] expression does not support [`ValueTuple`]

Open
#15,522 0 comments 1 reaction 0 assignees View on GitHub
Area-Queries Feature Request
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 11h
Merged PRs (30d)
131

Description

If I use `ValueTuple` in a query CE to execute query via EF Core 7
``` F#
let query = query {
for assessment in ctx.Set() do
select struct (assessment.TenantId, assessment.CompletedAt)
}
query.ToListAsync(cancellationToken)
```
I get `System.Exception: 'unreachable'`

**Describe the solution you'd like**

1. Current error must be more specific
2. `ValueTuple`s should be supported in this scenario

**Additional context**

Current code in the `FSharp.Core` 7.0.300
``` F#
let RewriteTupleType (ty: Type) conv =
// Tuples are generic, so lookup only for generic types
assert ty.IsGenericType
let generic = ty.GetGenericTypeDefinition()

match tupleToAnonTypeMap.TryGetValue generic with
| true, mutableTupleType ->
// Recursively transform type arguments
mutableTupleType.MakeGenericType(ty.GetGenericArguments() |> Array.toList |> conv |> Array.ofList)
| _ ->
assert false
failwith "unreachable
```

![image](https://github.com/dotnet/fsharp/assets/2365592/463756f2-b0db-473f-8aa8-bbd4c623ef16)

If the issue is about:
* related: #1103, #3782

Add any other context or screenshots about the feature request here.

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.