Data Access has been discontinued. Please refer to this page for more information.

How to: Execute a Query Using a Stored Procedure

Many application developers and database administrators use stored procedures to enforce security, provide predictability, and encapsulate logic on data inside the database. Application code that retrieves data which is mapped to a stored procedure uses a function identified by the FunctionAttribute.

To run the code in this example, you need a fluent model based on the Northwind database. You will need to create a context method for the CustOrdersOrders stored procedure.

The following code runs the stored procedure to return results.

using ( FluentModel dbContext = new FluentModel() )
   object[] custOrdersOrders = dbContext.CustOrdersOrders( "ALFKI" ) as object[];
Using dbContext As New FluentModel()
 Dim custOrdersOrders() As Object = TryCast(dbContext.CustOrdersOrders("ALFKI"), Object())
End Using

Working with Telerik Data Access ADO API

Besides querying the fluent model by using standard LINQ expressions, you can use the Telerik Data Access Low Level ADO API as well. Using LINQ queries is simple and easy. However, if you are concerned about the performance and comfortable writing ADO.NET like code, then the Telerik Data Access Low Level ADO API is perfect for you, because it allows you to execute stored procedures and materialize entities from the result set.

For more information, please refer to Low Level (ADO) API.

See Also