StringClob FTL

Found another Castle ActiveRecord/NHibernate gotcha today.

I had string columns being noisily truncated in my ActiveRecord types. Grr. I google and find a solution in the ActiveRecord FAQ: add a ColumnType="StringClob" to the property attribute.

[Property(ColumnType="StringClob")]
public String Contents
{
    get { return _contents; }
    set { _contents = value; }
}

Silly me though, I expected that to actually work as advertised. It doesn’t.

When you use ActiveRecord to create your schema, it will create the above column as a NVARCHAR(255). OMGWTFBBQ?!

The solution is to add an SqlType = "NTEXT" to your attribute as well.  Mmm, cryptic.

[Property(ColumnType = "StringClob", SqlType = "NTEXT")]
public string Description { get; set; }

Please refer to the following for further discussion of the issue.

Comments (3) left to “StringClob FTL”

  1. Shey wrote:

    you’re using underscores now?

  2. James Thigpen wrote:

    Yeah that wasn’t my code, I pasted. Underscores also FTL.

  3. atx wrote:

    or you could use nvarchar(max) under SQL Server >= 2005

Post a Comment

*Required
*Required (Never published)