-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute a query and map it to a list of dynamic objects #2344
Comments
(+ 1) |
So extend this to FromSQL method |
+1 |
**NOTE this was written against pre RTM version of .Net core and may need to be modified to work with 1.0 RTM and newer versions of the framework Attached is some code that provides this functionality with the existing framework. Let me know if this helps any.
Usage:
You will notice I used a Dictionay<string, object> since there are still some issues with passing a DbParameter currently - Support passing DbParameter instances to raw SQL APIs #3115 |
@ChristineBoersen tried your code and got
|
Unfortunately, the code snippet above was written before the framework went to RTM, so I would expect it to break at this point. I've edited the post to indicate that as I've moved away from EF for my current projects. |
In ChristineBoersen code Just replace dbContext.Database.GetDbConnection().CreateCommand() with |
just change GetDbConnection |
|
@Displee You need to "extend" the DbContext class and copy the code provided by @ChristineBoersen The method is an extension method. |
Hi @ChristineBoersen, Thank you for the solution. I am using the same to execute my stored procedure that returns dynamic fields. but DataReader doesn't return any rows. However procedure returning 2 rows with 8 columns. Even DataReader returing 8 in fieldscount, which is same as procedure returning.
and here calling method -
Here is my procedure result. Any help please?? |
please extend
DbContext.Database.SqlQuery
to support dynamic type for map query to a list of dynamic objects. for example:The text was updated successfully, but these errors were encountered: