Linq over Stored Procedures

后端 未结 9 517
长情又很酷
长情又很酷 2021-01-05 11:19

What are some pros and cons of using linq over stored procedures?

9条回答
  •  抹茶落季
    2021-01-05 11:58

    I use LINQ-to-SQL extensively in my projects, and have found it to perform as well as SP's in almost all cases.

    There are some cases in which you lose performance/ability by using LINQ-to-SQL, without a doubt:

    • Since queries are wrapped up in code by using LINQ, you can't use SQL's built in query optimizer/index optimizer tool (as easily). Things like tracing the execution plans take an extra step as well (getting the sql that is generated). Pretty trivial I guess.

    • If you have a really low-bandwidth situation, sending the extra text of the paramaterized query across the wire will eat up more bandwidth than just sending the stored procedure call. So if you're writing a windows app that communicates over a modem connection, this could be more of a concern than a web app (where the servers are sitting next to each other), or if you're in a really high usage situation.

提交回复
热议问题