I have a page where the user can input a SQL query. This query can be against any table in my database. I need to execute this query against the corresponding table and show the result in my view. How to do this?
For eg: user can input Select * from ABC or select max(price) from items.
I tried:
var results = DbContext.Database.SqlQuery<string>(query).ToList();
But this throws an error:
The data reader has more than one field. Multiple fields are not valid for EDM primitive or enumeration types.
Whatever the result I should be able to pass it to the view and display it.
Please help.