views:

229

answers:

2

Linq-To-Sql enables calling SPs. If this SP executes an update/delete/insert, do I need to SubmitChanges() after it?

+6  A: 

No you don't. The code will work. Submit changes is only concerned with modified LINQ to SQL objects and not stored procs.

RichardOD
A: 

(Please excuse me, I'm relatively new to LINQ)

Yes, but won't a stored procedure bypass the datacontext object and modify the database itself? (whereas linq modifies the datacontext object only, until the datacontext.submitchanges method is called, where it then modifies the database)

Can I have a stored procedure modify my datacontext object somehow? Does it already do this?

Can I have it so that

  • if I call a SP with linq (and I'm assuming that it directly modifies the database),

  • then use linq to modify my datacontext object, and submit the changes I made to my datacontext object,

the two different changes I made (One with the SP, the other with Linq to my datacontext) won't interfere?

What I really want is a way to have my stored procedures modify my datacontext. Is this possible?

I should mention that I'm converting a website from SQL to LINQ that has mainly stored procedures and trying to pick my battles with which stored procedures to convert to LINQ and which to keep in SQL and just make SP calls to them with LINQ.

Thank you for your help, -Jeff

Jeff R
I'm sorry if this is a little bit off-topic, but the topic question is what I'm trying to get at - how does submitchanges interact with stored procedures
Jeff R
i think you should post this as a question. But a stored procedure will not affect changes to the datacontext that you haven't submitted yet.
Jader Dias
Thanks, and does this mean that a stored procedure call made before a submitchanges call will give a conflict when I submit changes?
Jeff R