Just some off topic and unsolicited advice: You should probably not start your programming career at a place where noone knows and cares about building things the right way.. Friend of mine started at a similar company and got stuck learning everything the wrong way for 2 years before moving to the company i worked at and he had to start all over..
Timm
@Timm
Best posts made by Timm
Latest posts made by Timm
-
RE: Weekday weirdness
-
RE: Completely missing the point
@serguey123 said:
This result could probably be improved but adding a new layer will always degrade performance a bit, everything is a tradeoff
Agreed, but the query that came out of EF was so bad that it deadlocked our orders database which is also used to store new orders active users on the website are making. A little to much tradeoff. :)
-
RE: Completely missing the point
@Xyro said:
Tell me more about this. And are there straightforward ways to bypass EF while still using its features if need be, or does that create more problems like on some ORMs? Or is the way to bypass it just to use raw ADO.NET (which imo is as bad as JBDC if not worse)? I suppose if Dapper exists, then there isn't a feature in EF that basically allows you to do what the OP did? I would like to know more about your experience here.
Depends on what you want to do. You can easily bypass a very complex LINQ query by creating an SP and mapping that to the EF model. That and LINQ which generates decent SQL for 95% of the time will be good enough for a lot of applications.
What i dont really understand myself is that they seem to actively try to make it a cool gimmick..Example: http://blogs.msdn.com/b/adonet/archive/2011/03/15/ef-4-1-code-first-walkthrough.aspx
I tried it and its really superawsome when you are hacking a simple website or fast demo but big projects just dont work this way..#edit: have been a lurker so far and you need to type in HTML to post anything with layout, or am I just blind?
-
RE: Completely missing the point
In this case the LINQ part does a search and a sort in a giant list of objects. This is never as fast as doing it in SQL. Linq-to-SQL and EF can translate these kind of query's to SQL so it will be done in the database. The OP's query looks something like this with EF:
BlablaContext context = new BlablaContext();
IQueryable<Users> users = context.Users.Where(u => u.Salary < 40000).OrderBy(u => u.Salary);
foreach (var u in users)
{
//This is the moment the database query is executed
}
I use EF a lot. Setting it up in your application is very easy as someone asked. It works great in simple situations, but there is definately a limit in what it can do. We found the limit when we tried to get all order for the last 30 days out of the database of a big online shop. Added a lot of where clauses and grouping and sorting and it turned into a monster that took 5 minutes to run. My SP did it in 15 seconds..
TLDR: EF is cool but can't do everything you ever wanted in life..