This is a migrated thread and some comments may be shown as answers.

Stored Procedure with OpenAccess ORM

1 Answer 65 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vipin
Top achievements
Rank 1
Vipin asked on 13 Aug 2013, 11:07 AM
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>()
       {
        pOrderDetailID
};
 
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?

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 15 Aug 2013, 06:57 AM
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.

Regards,
Damyan Bogoev
Telerik
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.
Tags
Getting Started
Asked by
Vipin
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or