Column.DbType affecting runtime behavior
Posted
by leppie
on Stack Overflow
See other posts from Stack Overflow
or by leppie
Published on 2009-04-15T12:10:54Z
Indexed on
2010/05/09
11:18 UTC
Read the original article
Hit count: 234
Hi
According to the MSDN docs, the DbType property/attribute of a Column type/element is only used for database creation.
Yet, today, when trying to submit data to an IMAGE column on a SQLCE database (not sure if only on CE), I got an exception of 'Data truncated to 8000 bytes'. This was due to the DbType still being defined as VARBINARY(MAX) which SQLCE does not support. Changing the type to IMAGE in the DbType fixes the issue.
So what other surprises does Linq2SQL attributes hold in store? Is this a bug or intended? Should I report it to MS?
UPDATE
After getting the answer from Guffa, I tested it, but it seems for NVARCHAR(10) adding a 11 char length string causes a SQL exception, and not Linq2SQL one.
The data was truncated while converting from one data type to another.
[ Name of function(if known) = ]
A first chance exception of type 'System.Data.SqlServerCe.SqlCeException'
occurred in System.Data.SqlServerCe.dll
© Stack Overflow or respective owner