In our previous blog regarding the new Telerik OpenAccess ORM features about to be released in Q3 2011, we have presented to you our OpenAccessLinqDataSource. We will continue by showing you our new product enhancement for using stored procedures in an easier and straightforward way.
Supporting stored procedures is nothing new for OpenAccess ORM – you can already execute them through our ADO API. However, in order to do that you needed to instantiate the parameters or commands first and then call the appropriate method of OpenAccessContext. Naturally, in these cases the most common solution is to write an additional method for each stored procedure, encapsulating all the required information needed to invoke it, executing it and returning the results.
Now you don’t even have to create the methods. We have introduced the Stored Procedure Editor and it is doing it for you! Not only that you don’t have to write any code to instantiate the correct parameters, but it also hides the ADO API calls so you can use it without having any experience whatsoever with our low level API. The result method is created in your OpenAccessContext class and it can be invoked easily anytime, anywhere, as long as there is an instance of the context available.
Once the stored procedures are retrieved through the Add New Item wizard or Update from Database wizard, they will become available in your Model Schema Explorer:
Have a look at the capabilities the Stored Procedure Editor is bringing you:
- Map the stored procedure to a void method:
- Create a method mapped to a stored procedure with Scalar type:
- Map stored procedure results to a Persistent type:
- Map the results to a Complex type:
- Handle multiple result sets returned by a stored procedure:
The multiple results sets are handled by generating methods with different return types for calling the stored procedure. For the procedure on the image, we might for example have methods GetCarInfo and GetCarOrders, the first returning a Complex type and the latter returning the RentalOrder Persistent type.
In the end, all the methods generated through the Editor are going to become a part of the Domain Model code generation and can always be modified through the same configuration window for your convenience.
The Stored Procedure Editor is a great addition to the OpenAccess ORM, but be sure that we’ll surprise you with other exciting new features in the upcoming Q3 2011 release!
Ivailo Ivanov is Team Lead in Telerik Data Access