Last post Sep 19, 2014 03:29 PM by Mikesdotnetting
Sep 19, 2014 02:16 PM|mandrews1234|LINK
I'm branching a new feature of an existing website and it's rather large. Previously, everything has been done with sql queries using some custom classes to actually access the database and retrive data, to make sure that connections will always get closed
even on errors, and other things like that. The guys I work with are pretty damn good at writing sql queries, but I almost feel like they're so good with sql, they do too much business logic in actual queries, instead of in code, which makes it tough for someone
not super well versed in sql (like most coders I know), to debug.
I've always been a fan of linq, mainly because using objects and intellisense makes every thing easier, because you don't have to worry about mispelling a column name, giving it a wrong data type, etc.
However, given the fact that more often than not retrieving the specific data we need requires multiple joins, and sometimes the joins even get complicated, I'm trying to decide if linq is still the route to go. I'd like to, but not only because I want to,
I need a solid argument or I know I'll get shot down by our head architect.
My questions are, should we maybe just stick to how we've been accessing the DB, since we have a solid system in place, and the sql queries get quite long most of the time? Or should I still go with linq? In my opinion, it makes development faster, simply
because you get to use intellisense. But I'd need a better argument than that to win my case.
Thoughts? And sorry for the long post.
Sep 19, 2014 03:02 PM|SheldonS|LINK
I remember attending some events when LINQ first came out, and while it isn't always the fasted way to go one thing always stuck with me. LINQ has the potential to write better SQL queries than a person might write. I wish I could find some solid links
for you about that but my search fu is weak right now.
You can always see the SQL generated by your LINQ - http://msdn.microsoft.com/en-us/library/bb386961(v=vs.110).aspx
Sep 19, 2014 03:29 PM|Mikesdotnetting|LINK
You can use Entity Framework with stored procedures. This might be a way to get
dinosaurs SQL hotshots to consider its use. However, these people generally think the T-SQL is an application programming language and love to stuff business logic in their SQL. EF's main appeal is that it
facilitates an OOP approach to development which DBAs just don't understand.