leeshuiwua / dapper-dot-net

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

Parameter size for strings with length larger than 4000 #164

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Related to defect #110:

On my project, we're using Sybase for database storage. If I insert an object 
that has string properties with length > 4000, I get an exception because 
parameter size is set to -1 (parameter size cannot be -1). An update with 
string properties the same size works without any problems.

This is on current version of dapper NET40

Our solution has been to change SqlMapper.cs:1791 from

if (item != null && ((string)item).Length > 4000)
{
    listParam.Size = -1;
}

to

if (item != null && ((string)item).Length > 4000)
{
    listParam.Size = 4000;
}

Original issue reported on code.google.com by bjorneri...@gmail.com on 18 Nov 2013 at 10:19

GoogleCodeExporter commented 9 years ago
DBString or another custom parameter type is probably your best option here; it 
might also be possible to register a custom type handler for string, but that 
isn't the option I would recommend

Original comment by marc.gravell on 5 Aug 2014 at 3:10