In your stored procedure, you can create a table variable (or a temporary table if table variables are not available to you) and insert @@ rowcount after each part of the stored procedure that affects the number of rows in the table, then make a selection from the table variable as the last operation in your storage procedure.
for instance
CREATE PROCEDURE myProc
AS
BEGIN
DECLARE @ra TABLE
(
rowsAffected INT,
queryName VARCHAR(50)
)
INSERT INTO sometable
SELECT col1, col2
FROM someothertable
INSERT INTO @ra (rowsAffected, queryName) VALUES (@@ROWCOUNT, 'insert into sometable')
DELETE FROM anothertable
WHERE thingID = something
INSERT INTO @ra (rowsAffected, queryName) VALUES (@@ROWCOUNT, 'delete from anothertable')
SELECT rowsAffected, queryName
FROM @ra
END
Then update your DBML so that the rows are available in Linq queries for SQL.
source
share