Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
i am using EF 4.0 how can i run raw sql Query

What I have tried:

using( var context=new EmployeeContext())
{
<pre>string Query="Select  * from employee";
}
Posted
Updated 14-May-17 8:52am
v2

1 solution

A simple Google search goes a long way. I found this in 5 seconds: Raw SQL Query in Entity Framework[^].
 
Share this answer
 
Comments
Maciej Los 14-May-17 14:53pm    
5ed!
awaisshabir 14-May-17 16:01pm    
I already find this link but this is not working in ef 4.0
Dave Kreskowiak 14-May-17 16:50pm    
Then try context.Database.ExecuteSqlCommand.
awaisshabir 17-May-17 1:31am    
you can use raw sql with the help of DbdataReader or DbdataAdpter.
Dave Kreskowiak 17-May-17 10:24am    
Yeah but since you're already using EF and ... nevermind. I don't want to know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900