none
Advantages of Linq to sql over procedures? RRS feed

  • Question

  • I'm just a beginner to ling framework,I would link to know what are the benefits of using linq to sql over general sql procedures with a simple example....?
    • Moved by Lisa Zhu Friday, November 16, 2012 5:50 AM linq to sql related (From:Visual C# Language)
    Thursday, November 15, 2012 7:01 AM

Answers

  • Hi,

    There's a lot to be found on this subject.

    A small selection of what can be found:

    Debugging - As debug point concern, as LINQ is part of .NET, we can use
    the visual studio's debugger to debug the queries but it is tough to debug the
    Stored procedure as it will not support the visual studio debugger.

    Deployment - In case of deployment, we need to provide an
    additional script for stored procedures to execute but in case of LINQ, it will
    complie into single DLL hence deployment becomes easier.

    Type Safety - As LINQ is type safe, the queries errors are type checked at
    compile time. Better suggest to use LINQ because it helps to encounter an error
    at the compile time rather than at runtime exception.
     

    The disadvantage with LINQ is, it is not a
    precompiled statement where as stored procedures are precompiled. In case of
    LINQ the queries need to be compile before the execution. So according to this,
    I can say stored procedures are faster in performance as compared to LINQ.

    More info (an extensive list) can be found here.

    Hope this helps


    Please mark the best replies as answers - Twitter: @rickvdbosch - Blog: http://bloggingabout.net/blogs/rick

    • Proposed as answer by Pieter Geerkens Thursday, November 15, 2012 7:19 PM
    • Marked as answer by Alexander Sun Thursday, November 22, 2012 7:27 AM
    Thursday, November 15, 2012 8:01 AM
  • I don't completely think that Advantages is a correct word. I have a post in my blog about best practices of LINQ to SQL. Take a look, it could clarify your understanding.

    http://msguy.net/post/2012/03/20/LINQ-to-SQL-Practices-and-approaches.aspx


    Please mark as reply if helped.
    Also visit my blog http://msguy.net/

    • Proposed as answer by Alexander Sun Tuesday, November 20, 2012 8:07 AM
    • Marked as answer by Alexander Sun Thursday, November 22, 2012 7:27 AM
    Thursday, November 15, 2012 11:19 AM

All replies

  • Hi,

    There's a lot to be found on this subject.

    A small selection of what can be found:

    Debugging - As debug point concern, as LINQ is part of .NET, we can use
    the visual studio's debugger to debug the queries but it is tough to debug the
    Stored procedure as it will not support the visual studio debugger.

    Deployment - In case of deployment, we need to provide an
    additional script for stored procedures to execute but in case of LINQ, it will
    complie into single DLL hence deployment becomes easier.

    Type Safety - As LINQ is type safe, the queries errors are type checked at
    compile time. Better suggest to use LINQ because it helps to encounter an error
    at the compile time rather than at runtime exception.
     

    The disadvantage with LINQ is, it is not a
    precompiled statement where as stored procedures are precompiled. In case of
    LINQ the queries need to be compile before the execution. So according to this,
    I can say stored procedures are faster in performance as compared to LINQ.

    More info (an extensive list) can be found here.

    Hope this helps


    Please mark the best replies as answers - Twitter: @rickvdbosch - Blog: http://bloggingabout.net/blogs/rick

    • Proposed as answer by Pieter Geerkens Thursday, November 15, 2012 7:19 PM
    • Marked as answer by Alexander Sun Thursday, November 22, 2012 7:27 AM
    Thursday, November 15, 2012 8:01 AM
  • I don't completely think that Advantages is a correct word. I have a post in my blog about best practices of LINQ to SQL. Take a look, it could clarify your understanding.

    http://msguy.net/post/2012/03/20/LINQ-to-SQL-Practices-and-approaches.aspx


    Please mark as reply if helped.
    Also visit my blog http://msguy.net/

    • Proposed as answer by Alexander Sun Tuesday, November 20, 2012 8:07 AM
    • Marked as answer by Alexander Sun Thursday, November 22, 2012 7:27 AM
    Thursday, November 15, 2012 11:19 AM
  • You will likely use both stored procedures as well as LINQ to SQL in your applications.  LINQ really isn't a replacement for stored procs at all (by design).  What it's a replacement for is ad hoc queries from code, and to that end it's almost always a superior option.
    Thursday, November 15, 2012 4:00 PM
  • Hi porcupine87,

    From your description, I ‘d like to move this post to  the most related forum.

    There are more  experts in this aspect, so you will get  better support and  may have more luck getting answers.

    Thanks for your understanding.

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 16, 2012 5:49 AM
  • Hi Porcupine87,

    LINQ To SQL provides a run-time infrastructure for managing relational data as objects. If you mean advantage s of Linq over stored procedure, I think Rick provide a nice post. If you want to know more about LINQ To SQL, please refer to article Michael posted.

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, November 20, 2012 8:06 AM