Hello,
using LINQ to call stored procedure, first we need to create new connection and map it on LINQ To SQL designer.
check this article for more detail: http://www.fryan0911.com/2009/05/what-is-linq-to-sql-introduction.html
If you already finished mapping the stored procedure on LINQ to SQL designer, lets move forward to the actual code. On the example below, I used the stored procedure "GetProductsByCategory" which accepts category as parameter.
using (NorthwindDataContext datacontext = new NorthwindDataContext())
{
//retrieve all product that are beverage using stored procedure "GetProductsByCategory"
var products = datacontext.GetProductsByCategory("Beverages");
//display all retrieved products from stored procedure
foreach(Product p in products)
{
Console.WriteLine(p.ProductName);
}
}
Hope this helpful!
Thanks