Feature Request: Adding Support for Tuples in DbContext.Database.SqlQuery<T>()
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
Currently, Entity Framework does not support using tuples as the generic type in the `DbContext.Database.SqlQuery()` method. This limitation makes it challenging to execute SQL queries that return columns that do not directly map to entities or predefined models in the code.
I would like Entity Framework to support tuples as the generic type in DbContext.Database.SqlQuery(). For example:
```csharp
var results = context.Database.SqlQuery<(int Id, string Name)>("SELECT Id, Name FROM TableName");
```
This would allow developers to work directly with strongly-typed tuple results, simplifying development and eliminating the need for additional classes to handle temporary or specific query results.
Contributor guide
Assessment
This issue has not been assessed yet.