Telerik blogs

Before Q3 2011 was live we have introduced you one of the major new functionalities you can find in the release – the new Stored Procedure Editor. It is the tool that allows us now to present our stored procedure support as feature complete.

Along with the visual interface the Editor is offering, we have enhanced the functionality that was available in previous OpenAccess ORM versions generating automatically methods in the OpenAccessContext that are calling stored procedures. The old version of this code generation used to produce methods such as this one:

// Old code generation
public object[] GetCarsDetails(string carMake)
{
    SqlParameter parameterCarMake = new SqlParameter("CarMake", OpenAccessType.Varchar);
 
    List<SqlParameter> sqlParameters = new List<SqlParameter>()
    {
        parameterCarMake
    };
 
    object[] queryResult = this.ExecuteStoredProcedure<object>("'GetCarsDetails' ?", sqlParameters, carMake);
 
    return queryResult;
}

With Q3 2011 release, the return types of the stored procedures are configurable, so the generated method for the same procedure could look like this:

// New code generation
public IEnumerable<MyNamespace.Car> GetCarsDetailsTyped(string carMake)
{
    OAParameter parameterCarMake = new OAParameter();
    parameterCarMake.ParameterName = "CarMake";
    parameterCarMake.Value = carMake;
    IEnumerable<WebApplication4.Car> queryResult = this.ExecuteQuery<WebApplication4.Car>("[GetCarsDetails]", CommandType.StoredProcedure, parameterCarMake);
 
    return queryResult;
}

 

Due to this flexibility, no stored procedure is automatically generated before you explicitly request it through the Stored Procedure Editor, specifying the desired result set. We are offering you plenty of options for it:

  • No result set
  • Scalar values (Int32, String, etc.)
  • Persistent type – any of you already mapped persistent classes
  • Complex type – a custom type that is created specifically for the result set of the stored procedure.

But the best improvement of all is the ability to define multiple result sets for your stored procedures - depending on what do you need to use the result for.

If you are using stored procedures with an older version of OpenAccess ORM and you upgrade to Q3 2011, you will find that all of your methods calling stored procedures are missing. We have already prepared a backward compatibility setting for you so that you can quickly get your code up and running again. You should just follow a simple set of instructions specified in the relevant Knowledge Base article.

Even with the old methods still there, you will be able to benefit from using the Stored Procedure Editor. You should just specify different names in the Editor for your new methods (instead of the default values) so that they do not overlap with the old ones.

In order to quickly start using the new Stored Procedure Editor in your application, take a look at the getting started video tutorial we have published on Telerik TV. Do not hesitate to let us know through the rating system whether you are having a great learning experience or we can improve our videos in some way.

In any case, the best way for evaluating our new stored procedure handling capabilities is to get your hands dirty, so download the new release and give them a try!


About the Author

Ivailo Ivanov

 is Team Lead in Telerik Data Access

Comments

Comments are disabled in preview mode.