brucezhang80 / dapper-dot-net

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

Inserting binary data over 8000 bytes into SQL CE fails #98

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Due to a limitation in SQL Server Compact Edition, the binary data type only 
supports 8000 characters, whereas the full SQL Server supports more, by using 
binary(max).

I've created a failing test to illustrate this behaviour:

https://github.com/tjrobinson/dapper-dot-net/commit/1ec61e5e0c7a829e25d9c0c9ba06
f2058f004300

What is the expected output? What do you see instead?

I am SQL Server Compact Edition 4.0 but I believe the same applies to previous 
versions of SQL CE.

The typeMap currently maps binary[] values to the binary data type:

typeMap[typeof(byte[])] = DbType.Binary;

For SQL CE, the image data type needs to be used when the size is over 8000 
bytes.

Additional information:

Microsoft Connect (Closed as By Design)
http://connect.microsoft.com/SQLServer/feedback/details/311412/sqlceparameter-li
mits-dbtype-binary-to-8000-characters-ssce3-5

A brief mention of this issue in another issue:
http://code.google.com/p/dapper-dot-net/issues/detail?id=24#c5

If you're wondering if it's ok to use the image data type then this is worth a 
read:
Does the deprecation of ntext, text, and image affect SQL Server Compact 
Edition?
http://stackoverflow.com/questions/10498882/does-the-deprecation-of-ntext-text-a
nd-image-affect-sql-server-compact-edition

Original issue reported on code.google.com by tjrobin...@gmail.com on 25 May 2012 at 3:32