2

There is a stored procedure that executes exec command and returns some columns. Columns and number of them are varied. How can I call this stored procedure from Entity Framework?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sosha
  • 207
  • 3
  • 11
  • 5
    This is a **horribly bad** design - and EF doesn't support it (and that's a good thing!). Your stored procedure should be **stable** and return one "shape" of data only - these "do it all" procedures are just really really ugly to use and to maintain - I'd strongly recommend **against** this practice! – marc_s Feb 19 '14 at 06:14
  • 6
    Well I basically agree, but whether a design is good or bad is always subjective, e.g. DOES depend on the context. – Bart Nov 03 '14 at 09:23
  • @Bart: I totally agree with you. we can not say it a bad design, although it might be a functional requirement. – Jitendra Pancholi Mar 29 '17 at 11:23

1 Answers1

-1

You have to create a ComplexType in the EntityFramework and then call the stored procedure:

public ObjectResult<yourComplextype> MyMethod()
{
 return _dbContext.usp_Yourprocedure();
}
Bhupendra Shukla
  • 3,814
  • 6
  • 39
  • 62