Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Experts,

I want to know that is it possible to write sql Queries with EF if yes then please tell me how to write.

Thanks
Posted
Comments
King Fisher 26-Nov-14 23:58pm    
Do not Repost

1 solution

Hi kishore,

U can acheive this task using following syntax:-


var blogs = context.Blogs.SqlQuery("SELECT * FROM dbo.Blogs").ToList();

Here context is ur context object , blogs is the table name after that you have to write
.SqlQuery() and inside that u can write ur sql query.

Actually when u will write Linq query's then internally it converts it to sql query.

Thanks
 
Share this answer
 

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