LINQ to SQL using Stored Procedures
The O/R designer tool of Visual Studio Web Developer 2010 provides an in-built feature of mapping database tables and the stored procedures or functions that can be used for querying and manipulating the data items stored in the data store. In the previous tutorial: LINQ to SQL and O/R Designer, we learnt about the utility of object relation designer tool that enables to generate the automatic DataContext class which allows to map the database table by dragging and dropping them on the designer's workspace. Similarly, you can drag and drop the stored procedures from database explorer on to the O/R designer to auto-generate the strongly-typed methods that provide the functionality to retrieve the data and populate the entity classes. The return types of methods generated by dragging and dropping the stored procedures or functions on the designer surface may differ depending upon the place where you drop them.
There are two ways of dropping a stored procedure on the designer surface. When the function or stored procedure is dropped directly onto an existing entity class, it creates a DataContext method with its return type as of the entity class. Whereas, when they are dropped onto an empty area then the O/R tool creates a DataContext method having an auto-generated return type.
Following are the different types of Stored Procedures or functions, based on the types of input/output parameters and their return types, which can be used in an LINQ driven web application:
Continue to next tutorial: LINQ to SQL Stored Procedures to Return Multiple Data Rows using C# to learn how to map a stored procedure that fetches multiple records from a database table.