Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to map ntext using NHibernate Mapping-By-Code feature of NHibernate 3.2?

I need to map ntext column of a table using the mapping by code feature in NHibernate 3.2, so that it doesn't get truncated to 4000 characters.

What do I neet to change in the following example? "Notes" is the property which has ntext type in sql table:

Property(emp => emp.Notes);

Note: Please don't mix it with fluent NHibernate or hbm file mapping.

like image 322
Baig Avatar asked Feb 01 '13 07:02

Baig


1 Answers

So, I solved the problem as following:

Property(emp => emp.Notes, map => map.Column(col => col.SqlType("ntext")));

Actually, all what we need to do is: tell the NHibernate mapper the actual type of the column in sql. :)

The solution comes from here as pointed by jbl.

like image 123
Baig Avatar answered Oct 21 '22 03:10

Baig