Accessing stored procedures using LINQ

Open ServerExplorer

Open NorthWindDataConnection

Drag & drop CustOrderList (Stored Procedure) on Form (which contains tables we drag & dropped (cust, order, - - - -))

(The stored procedure we already have)

Rclick anywhere on the design and click ShowMethodSpan. Now a window will be opened showing all stored procedure


Note: The above steps will add the definition of the stored procedure with LINQ to SQL classes.  

Inclined to build a profession as VB.Net Developer? Then here is the blog post on, explore VB.Net Training

The stored procedure used in LINQ:


@ Customer ID nchar (5)


SELECT Product Name, Total = SUM   - - >  (quantity)

FROM ProductsP, [Order Details] Od, Orders O, Customers c

WHERE C.CustomerID = @ Customer ID

AND C.CustomerID = O.CustomerID

AND O.OrderID = OD.OrderID AND

OD.ProductID = D.ProductID

GROUP BY Product Name

Click on GridView2 task and edit columns

Expand Command Field à Select à Add

Button type: button

SelectText: ShowOrders

Double click on GridView2


String cid;

TableCell tcCID = (TableCell) GridVIew2. SelectedRow. Cells [3];

cid = tcCID.Text;

Response.Redirect (“ShowOrdersHistoryByCID.aspx? cid = “ + cid);

Website [menu] - - >Add NewItem – Name: ShowOrdersHistoryByCID

Place a GridView Control

// Page_Load

String CustomerId = request.QueryString [“cid”];

NorthWindDBDataContext dc = new NorthWindDBDataContext ();

Var ordersHistory = dc.CustOrderHist (CustomerId);

GridView1.DataSource = orderHistory;

GridView1.DataBind ();

For an in-depth knowledge, click on below