I have a Linq to SQL data context class, where I am firing a stored procedure. I can trace through the generated code to where the stored procedure is being fired. I inspect System.Data.Linq.SqlClient.SqlProvider.ExecuteResult and can see that there is a private member called "value" which contains the number of rows updated. There does not appear to be any public accessor for that, and as well the result does not appear to be returned back to the data context anyhow. Is there some other way to access this value or do I have to return @@RowCount from every stored procedure (yuck) ?
A:
Hmm. Admittedly this is a "best guess" as I haven't tried it out with a stored procedure, but is this what you are looking for:
... Do Updates ...
// if sdc is your DataContext
int changedRecords = sdc.GetChangeSet().Updates.Count();
sdc.SubmitChanges();
That's for Updated records and you can replace .Updates with .Inserts and .Deletes as necessary. As long as the stored procedure is part of the data context it should be tracked by the GetChangeSet().
mark123
2010-01-09 04:50:34