Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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
 
Paresh
Posted 1-Jun-12 2:32am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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>
> 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!
  Permalink  
Comments
taha bahrami at 1-Jun-12 11:44am
   
when I paste the code, Was broken!:(
Paresh Solanki at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Update:
 
It does work, as long as your properties in the receiving class match column names being returned.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 345
1 OriginalGriff 210
2 DamithSL 210
3 Kornfeld Eliyahu Peter 210
4 Peter Leow 95
0 OriginalGriff 7,215
1 DamithSL 5,199
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,757
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 19 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100