I use C#, Linq and EF4.
I have a front end for my website, I need display (read only) data from my data base on my web pages.
I would like to know what could help me to achieve faster (read only) results to my users.
Here some idea I’m thinking to implement.
- A – Using Linq and Anonymous Types, so I can select just the proprieties I need to display (using EF) and save some memory. Please tell me if this would increase speed.
- B – Pre compiling my queries.
- C – Have the option tracking off for my objects BojectContext in EF.
Please tell what do you think specially for point A. Thanks for your help!
If you have the functionality working and if you need to optimise then I think the first step is to measure. As a first step, try using SO’s profiler to see where your app is consuming time http://code.google.com/p/mvc-mini-profiler/
After you’ve measured, then you can experiment with A, B or C – or you might identify a totally different area to optimise. (My own favorite area for EF optimisation is lazy-loaded sub-objects)
Update (in response to comment): Honestly I don’t expect A, B or C to gain you any significant time – you need to measure – it’s the only way to find out where optimisations can be made. Once you’ve measured then my guess is that none of A, B or C will save you any significant time at all.