when to use Linq To Entites and when to use stored procedure? RRS feed

  • Question

  • I need to have some parameters on base of which I can decide like where to use linq to entites & where to use stored procedure?

    For example if we have Insert scenario but that requires first IsExist check then if we use Linq it will make 2 database trip

    1. For IsExist

    2. For Insert

    while if we use StoredProcedure it will insert in one request.

    Also in which type of query we need to use linq or stored procedure?


    Thanks, Rajesh Khunt
    Monday, December 19, 2011 8:33 AM


  • Hi Rajesh,

    Welcome to MSDN Forum!

    Based on the issue, in my opinion, if you have already created the stored procedure, you can use the stored procedure in Entity Framework. If the stored procedure has not created, you need to think if the Linq to Entities can satisfied your requirement. Not all the T-SQL can be translated from Linq to Entities. Furthermore, if your project have a high level of efficiency, the Linq to Entities may not as good as stored procedure, but it’s more easy to write and understand.

    Best Regards

    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    • Marked as answer by Allen_MSDN Monday, December 26, 2011 1:22 AM
    Wednesday, December 21, 2011 1:56 AM