Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

New Post: Stored Procedure Return Types not set to custom type for all stored procedures

$
0
0
I figured out the problem. It is SET FMTONLY ON SQL that queries the stored procedure for results. The problem is the effect FMTONLY has on the stored procedure. I added this to the top of the stored procedure, and it returns results correctly. The incorrect results triggered a Try/Catch in your code to default to a result of int.
DECLARE @fmtonlyON BIT = 0;
IF (1=0) SET @fmtonlyON = 1;
SET FMTONLY OFF;
-- add a conditional to test for null parameters and return a single record of null values 
-- with correct field names and types, e.g., convert(nvarchar(450), null) as myfield
You wouldn't think 1 would ever be equal to 0.

Also, the code seems to produce multiple result sets for stored procedures that have conditional result sets because of the FMTONLY. One could either add to the POCOs to create Entities for the stored procedures in code, or worse case add empty tables with the fields and datatypes of the SP, then force the result of the SP like your statement above (in purple.) Of course, you are correct about not having List<> included after fixing up FMTONLY so the try/catches do not fire. When it defaults to int, the code fails because I think the result set must be an entity (to have ResultSetModel1 as a property,) but this just seems to be an effect of the original error as the ResultSetModel1 resolves correctly after the fix.

Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>