DBContext Native SQL Queries

affejr

New Member
How to use native queries with \[code\]DBContext\[/code\] ? If I run the code, this give me exception. Why and what to do to run native query when using \[code\]DBContext\[/code\] ? \[code\]AcademyEntities context = new AcademyEntities(); string nativeSQLQuery = "SELECT * " + "FROM dbo.Employees " + "WHERE FirstName='{0}'"; string name = "Guy"; var emp = context.Departments.SqlQuery(nativeSQLQuery, name); foreach (var item in emp) { }\[/code\]
 
Back
Top