Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How LINQ is beneficial than Stored Procedure ?

user-image
Question added by Deleted user
Date Posted: 2016/02/18
Deleted user
by Deleted user

LINQ has good advantage over stored procedures:

  • Debugging  :  Debugging the stored procedure is hard. With visual studio’s debugger we can easily debug LINQ queries.
  • Deployment  : LINQ deployment is easy. For SP we need to provide scripts but in LINQ everything’s gets compiled into a single DLL.
  • Type Safety  : LINQ is type safe. Errors are checked at compile time.

The query when executed against Sql Server, which in turn needs to generate an execution plan for the query and run it against the table to get the results. It's pretty efficient at creating the right query for the right job, and supports more of an ad-hoc approach to data querying.

With stored procedures, Linq-to-Sql doesn't have to generate an expression tree and from that generate the sql, instead the designer generated class has all in information it needs to pass the arguments from the method to the stored procedure.

 

In that sense, its more efficient to use stored procedures, but you lose the ability to do these ad-hoc queries which are so often useful.

More Questions Like This