I’m looking for a way to do something like this:
var db = new DALEntities();
db.StoredProcedureToCall();
but, I want it to be dynamic, in that I won’t know WHICH call to make until after some other data is delivered to me.
var db = new DALEntities();
db[tSproc]();
I know I could have a switch statement test the value of tSproc, and then call as above, but is there a more elegant way?
Thanks
Put your cursor on
db.StoredProcedureToCall()and press F12. You’ll see the code that EF generated is already dynamic.Depending on the EF version you use, it will look something like:
Just write your code similarly. You don’t need a switch.