Why do I need Stored Procedures when I have LINQ to SQL

前端 未结 18 1068
栀梦
栀梦 2021-02-05 15:59

My understanding of Linq to Sql is it will take my Linq statement and convert it into an equivalent SQL statement.

So

var products = from p in db.Product         


        
18条回答
  •  感情败类
    2021-02-05 16:29

    I can think of several good reasons for stored procedures:

    • When working with bigger tables, it can be hard to generate an efficient query using LINQ to SQL.
    • A DBA can analyze and troubleshout stored procedures. But think of what happens when two complicated LINQ operations from different front-ends clash.
    • Stored procedures can enforce data integrity. Deny write access on tables, and allow changes only through stored procedure.
    • Updating stored procedures is as easy as running ALTER PROCEDURE on a server. If a deployment takes months, and a script minutes, you'll be more flexible with stored procedures.

    For a small application that's maintained by one person, stored procedures are probably overkill.

提交回复
热议问题