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.

This entry was posted in Development. Bookmark the permalink.

3 Responses to StringClob FTL

  1. Shey says:

    you’re using underscores now?

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

  3. atx says:

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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>