Raw store access: Support execution of SQL that returns results but is not composable on the store, e.g. stored procedures
See original GitHub issueWe should provide a simple mechanism to execute queries/commands such as regular stored procedures that contain a SELECT statement. What FromSql()
does won’t work for those because you cannot used them as sub queries.
A few things we could use:
- Provide an API akin
FromSql()
but switch composition to in-memory if subsequent LINQ operators are applied. Same warning and kill switch for query evaluation we have talked about having for other queries would apply to these. - Provide a completely separate API pattern that is meant for non-composable results and even not return
IEnumerable<T>
but a new type that implementsGetEnumerator()
andAsEnumerable()
- Stick the stored procedure results into a table-valued variable and then keep composing as normal. This would move processing to the server and make composition more seamless but would most likely not make it any more efficient than option (1).
- Recognize the token “EXEC” in
FromSql()
(which is pretty standard although no longer required) for SQL Server as an indication that what follows is a non-composable stored procedure and that needs to go through a different execution mode (e.g. the one described in (1) or the one described in (3)).
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
Include with FromSqlRaw and stored procedure in EF Core ...
I am getting: FromSqlRaw or FromSqlInterpolated was called with non-composable SQL and with a query composing over it. Consider calling ...
Read more >SQL Queries - EF Core
Using SQL queries in Entity Framework Core. ... SQL queries can be used to execute a stored procedure which returns entity data:.
Read more >Stored Procedures with Multiple Result Sets - EF6
This article will show you two ways that you can use to access more than one result set from a stored procedure in...
Read more >Using Stored Procedures with Return Values
In this article, we will learn how we can use a Stored Procedure with return values with all details. Introduction.
Read more >Data definition language (DDL) statements in GoogleSQL
Data definition language (DDL) statements let you create and modify BigQuery resources using GoogleSQL query syntax. You can use DDL commands to create, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have made this to call stored procedure and map the DataReader to a specified model. I hope it helps.
We don’t currently have support for named parameters in
FromSql
andExecuteSqlCommand
. There are plans to support other patterns in the future (i.e.SqlParameter
,DbParameter
, anonymous types), but for now you should be able to use the somewhat clunky pattern that we use inFromSqlSprocQuerySqlServerTest
: