Support object/dynamic in SqlQueryValueAsync
See original GitHub issueI have a use case where I must query a dynamic database (columns might get added/removed by another system). I have a query generator that generates raw SQL queries.
I’d like to be able to do this:
var data = await _context.SqlQueryValueAsync<IEnumerable<object>>(query, cancellationToken: cancellationToken);
or
var data = await _context.SqlQueryValueAsync<IEnumerable<dynamic>>(query, cancellationToken: cancellationToken);
or
var data = await _context.SqlQueryValueAsync<object>(query, cancellationToken: cancellationToken);
or
var data = await _context.SqlQueryValueAsync<dynamic>(query, cancellationToken: cancellationToken);
Currently, I’m getting:
System.NotSupportedException: Invalid operation, supplied type is not a value type
Provide steps to reproduce
Consider a query like this:
SELECT TOP 100 * from dbo.Users;
or
SELECT name, surname, agefrom dbo.Users where id=1234;
Provide technical details
Searching over the net I found this: https://github.com/dotnet/efcore/issues/2344#issuecomment-172641417, but ideally, this should be added to this library.
-
EF Core version in use: (e.g. EF Core 6)
-
Is Handlebars used: no/yes
-
Is .dacpac used: no/yes
-
EF Core Power Tools version: (found in About dialog - blue questionmark icon on context menu)
-
Database engine: (SQL Server, Azure SQL, Postgres, Oracle, Firebird, SQLite, MySQL)
-
Visual Studio version: (e.g. Visual Studio 2022)
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Sure: https://github.com/dotnet/efcore/issues/10753
Could you please add link to EF Core issue for that?