Does EF support this out of the box?
You should be able to call SqlQuery with parameters, so it will take care of SQL injection, etc., just like SqlCommand does:
var tests = context.Database.SqlQuery<Test>( @"SELECT Id, Name FROM tests where Name={0}", "TestName");
or..
var tests = context.Database.SqlQuery<Test>( @"SELECT Id, Name FROM tests where Name=@name ", new SqlParameter("@name", "TestName"));
source share