I have an nvarchar (2000) column in a SQL Server 2005 database and mapped to it in NHibernate as:
<property name="Query" column="`Query`" type="String" length="2000" not-null="false"/>
The DTO class simply represents a string property:
public virtual string Query { get; set; }
If I set the query to a string of> 2000 characters, I get an exception from the SQL server as a result:
"String or binary data will be truncated. The application has been discontinued."
I want this truncation to just happen automatically and quietly. I could override the virtual property and forcefully remove the truncation in the property set, but I feel that there should be a way to get this behavior by default, either by matching NHibernate, or even as an SQL server parameter.
I am missing nothing ... I do not want to change the db scheme to have longer lines.