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

How to: Execute a Query Using a Stored Procedure

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

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 to create a new Telerik Data Access Domain Model based on the Northwind database. You will need to include all stored procedures from the Northwind database.

The following code runs the stored procedure to return results.

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

Working with Telerik Data Access ADO API

Besides querying a Telerik Data Access Domain Model by using standard LINQ expressions, there is one more way you can query the domain model, and that is through the Telerik Data Access ADO API. 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 ADO API is perfect for you. The Telerik Data Access ADO API 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