Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All.

I have a requirement to be able to run a stored procedure in C# with Entity Framework 4, connecting to an Oracle 11 db.

I can do this when the SP is known at compile time, but often this is not the case as different clients have different stored procedures.

The question is this: Is it possible for my program to determine at runtime which stored procedures to run and to return recordsets from them?

For example:
Client 1 has the Stored Procedures A & B.
Client 2 has the Stored Procedures A, C & D.
Client 3 has the Stored Procedures E & F.

At the moment I would need a separate mapping and new code to satisfy all three clients, and if a fourth came along that would need yet another variant.

Is there any way of determining and executing these at runtime rather than compile time?

Thanks in advance


i can't find a way to add sp dynamically bau use this method could help you:
DataContext.Context.ExecuteStoreQuery<ilist><roles>>("seleci id from...",param object[] params);</roles></ilist>

<ilist><roles>></roles></ilist> means that the return value is a list of Roles(a table in my database) entity, in entry method you set the query script as a script, and at least add params as object[] to this method!
sorry this is not the solution that you want, but maybe this can help you a little!
Share this answer
taha bahraminezhad Jooneghani 1-Jun-12 11:44am    
when I paste the code, Was broken!:(
Paresh Solanki 11-Jun-12 7:25am    
Hi Taha

This looks like it could work. It's an improvement on my 'temp' solution anyway.

I'll play with it and let you know.

Any idea on how to return a dataset with this method? The stored procedures are designed to return a set of rows with calculated values. The returned rows will mimic an existing table structure that is already mapped in the edmx.

It does work, as long as your properties in the receiving class match column names being returned.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900