jdiaz
jdiaz

Reputation: 7472

Linq-to-SQL Executing NonQuery

Is it possible to use Linq-to-Sql to execute a stored procedure that does not return an output?

Upvotes: 1

Views: 1983

Answers (3)

p.campbell
p.campbell

Reputation: 100607

In the Server Explorer window, browse and find your sproc. Drag it over to the Methods area in the Linq-to-Sql designer.

This stored procedure is now available as a method in your DataContext object.

e.g.

Your sproc name is IncrementCustomerVisit and it takes one parameter of type int.

In your app code:

using (DataContext db = new DataContext())
{
   db.IncrementCustomerVisit(someCustomerID);                 
}

Upvotes: 5

Paul Rowland
Paul Rowland

Reputation: 8352

db.ExecuteCommand("exec myStoredProcedureName");

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1502126

DataContext.ExecuteCommand?

Upvotes: 5

Related Questions