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?
-
5This 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 6:14
-
6Well I basically agree, but whether a design is good or bad is always subjective, e.g. DOES depend on the context. – Bart Nov 3 '14 at 9: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
Add a comment
|
You have to create a ComplexType in the EntityFramework and then call the stored procedure:
public ObjectResult<yourComplextype> MyMethod()
{
return _dbContext.usp_Yourprocedure();
}
-
2Sure - but if the "shape" of the data changes with each call - what is this complex type going to be?? – marc_s Feb 19 '14 at 6:14
-
-
@marc_s I think we can also call the sp without using ComplexType – Bhupendra Shukla Feb 19 '14 at 6:17