I am using ASP.NET MVC with EF 5.0. I am trying to create a dynamic query and execute it using EF.
What I tried
var sConnection = ((SqlConnection)DbContext.Database.Connection);
sConnection.Open();
Thought I will take the EF connection and use that and execute the query and get result in DataTable
.
But I saw other option of
DbContext.Database.SqlQuery //But I need to have Entity Type to get the results
DbContext.Database.ExecuteSqlCommand
Is there a way I can execute and get results to DataTable
without using my way of getting connection object ?
Any other alternative and best approach wil be useful,
Thanks