eswartechraq / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

SqlProcedure changes Resultset resulting in Error #179

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create model with property "string col"
2. Create Stored procedure which returns dbnull ("select null as col")
3. Start application and call it once
4. Alter Stored procedure to return int ("select 'asd' as col")
5. call it again, it fails

What is the expected output? What do you see instead?
The "col" property should be null the first time, after the change it should be 
"asd". Instead the application crashes because Dapper cached the resulting 
columnset which did not contain the information about the string type.

What version of the product are you using? On what operating system?
Dapper 1.2.5, Win7 x64

Please provide any additional information below.
Only a cast of null to varchar(max) like "select convert(varchar(max), null) as 
col" can fix the problem.

Why do I encounter this problem?
Our database team is changing the database layer which is strictly done with 
stored procedures. In this particular case the initial value of a column was 
null because the structure didn't exists yet in the database at the time I was 
writing my code. After some time the guys fixed the structure and changed the 
column value to a table-field.

Is there a way to avoid that problem? maybe to say "whenever you encounter a 
DbNull don't cache it"?

Original issue reported on code.google.com by masta2ooo on 16 Jun 2014 at 4:32