I am using ASP.Net4.5.1 & EF6.0 Code-First approach.
I realised that queries are taking considerable time to execute. I have used EF Profiler to check the queries & fine-tuned the queries.
I googled & came to know Compiling Linq.
These are the links I got.
- https://stackoverflow.com/questions/32175040/how-to-cache-queries-in-ef-code-first
- How do I precompile an Entity Framework Code-First Query?
- Entity Framework Compiled Query
But none of them that address my concern.
Suppose I have below query.
public IEnumerable<Student> GetStudents()
{
using(DbContext db = new DbContext()
{
IQueryable<Student> query = (from c in db.Students
where c.Hobby== "Hockey"
select c);
IEnumerable<Student> students= query.toList<Student>();
return students;
}
}
Now how do I cache the query plan or compile this Linq to increase the performance?
One more thing to ask here, is EF slower than native SQL?
I prefer to use EF/ORM, is it right choice?