Stored Procedure with OpenAccess ORM

Thread is closed for posting
2 posts, 0 answers
  1. Vipin
    Vipin avatar
    2 posts
    Member since:
    Jan 2013

    Posted 13 Aug 2013 Link to this post

    I have requirement. I have a stored procedure which returns a result set.The result set is dynamic. So I am unable to create a specific model for the result. I have to generate an Excel from the application based on the Result. I need to call the SP from EntityModel, but can't use a specific model to retrieve data. Right now I am using this code:

    using (EntitiesModel1 ctx = new EntitiesModel1())
    Telerik.OpenAccess.SqlParameter pOrderDetailID = new Telerik.OpenAccess.SqlParameter("OrderDetailID", OpenAccessType.Int32);
    List<Telerik.OpenAccess.SqlParameter> sqlParameters = new List<Telerik.OpenAccess.SqlParameter>()
    object queryResult = ctx.ExecuteStoredProcedure<object>("[sp_OrderDetailView]", sqlParameters, orderDetailID);
    return queryResult;

    But this code basically returns an Object Array, from which I am unable to read the Field/Column name. 
    Is there a method using which I can get a DataSet which I can easily parse and generate the Excel?
  2. Damyan Bogoev
    Damyan Bogoev avatar
    581 posts

    Posted 15 Aug 2013 Link to this post

    Hello Vipin,

    I am afraid you cannot achieve this goal out-of-the-box. You could use the OpenAccessContext.ExecuteQuery<TResult>(...) in this scenario with object, persistent type or a complex type as a generic argument. This means you have to be aware of the result shape at the moment you are using the Context API method. 

    You need to combine the ExecuteQuery method with some additional logic, which accounts for the result shape returned, to be able to consume the stored procedure result correctly.

    Hope that helps.

    Damyan Bogoev
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Back to Top