I’m calling a stored procedure which does some updates/inserts/deletes (any one of these at a time) from Linq. This stored procedure is added to datacontext I’m using. After calling this stored procedure I want to get the number of rows affected by this stored procedure. This stored procedure may affect more than one table also.
I tried using GetChangeSet method of datacontext but it doesn’t return affected rows count for inserts/updates/deletes performed in this stored procedure.
I dont want to use @@rowcount and return that rowcount as return value.
Is there any way I can find this affected rows count?
In your stored procedure you could create a table variable (or temp table if tables variables are not available to you) and insert @@rowcount into it after every part of you stored procedure that affects the row count of a table, then do a select from the table variable as the last operation in your store procedure.
For example
Then update your DBML so that the rows are available in Linq to SQL queries.