0

I have an MVC 3 project. In sql server I have a field called NewsContent which is a text field.

Here is the definition of the property in the Model:

    [Display(Name = "Content")]
    [DataType(DataType.MultilineText)]
    [AllowHtml]
    public virtual string NewsContent { set; get; }

When i save it to database it truncates. Well it is Text why is it truncating?

How can i fix it?

I can see in debugger that the object has all the text, when I look at database it is truncated.

4
  • What type is the database field, and size? Commented Oct 5, 2012 at 3:03
  • NewsContent and type is Text
    – DarthVader
    Commented Oct 5, 2012 at 3:03
  • Sorry, should have asked for the nh map as well. Fluent statement, xml, or whatever Commented Oct 5, 2012 at 3:08
  • fluent Map(x => x.NewsContent); I dont know if that matters.
    – DarthVader
    Commented Oct 5, 2012 at 3:10

2 Answers 2

4

Try this:

Map(x => x.NewsContent).CustomType("StringClob").CustomSqlType("nvarchar(max)")
0
0

In some NHibernate versions this truncating behavior was present due to the underlying ADO.NET having this behavior in certain circumstances. This was changed in NH 3.3 so that if the string is longer than allowed, NHibernate will throw an exception.

The above applies when using MS SQL Server as the database. If you are using this database, or still seeing this issue in this version of NHibernate, it should be regarded as bug that should be fixed. Please report it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.