Today I just discovered Google’s custom search engine program, and quickly setup a .NET Search Engine. I have restricted the list of sites to those that cater to .NET topics including non other than geekswithblogs, in addition to others.
Month: October 2006
NHibernate and Text fields
In my last post about NHibernate I mentioned using NHibernate.Mapping.Attributes to simplify things.
Since my last post I have had the need to store rather large text data in a SQL Server Text field. My initial attempt was to simply create a C# string property that represented the field as such:
[NHMA.Property(Name="SomeData")] public string SomeData { get { return _someData; } set { _someData = value; } }
I was shocked to learn that the above did not work correctly. What I was experiencing was NHibernate was silently truncating my data to 3000 characters (or maybe it was 4000, I can’t remember exactly). The reason for this appears to be that NHibernate assumes the field type to be of varchar not Text.
The solution to this problem is to inform NHibernate of the field’s true type. As it turns out this can be done by specifying it as type ‘StringClob’.
[NHMA.Property(Name="SomeData",Type="StringClob")] public string SomeData { get { return _someData; } set { _someData = value; } }