I’m constructing a query like this:
private void Test()
{
ISession session = sessionFactory.OpenSession();
var query = session.GetNamedQuery("testQuery");
string s = BuildVeryLongString(); // length more that 4000 chracters
query.SetParameter("Param", s, NHibernateUtil.String);
query
.SetResultTransformer(new AliasToBeanResultTransformer(type))
.List<Type>();
}
In the DB-profiler I can see that the type of Param is nvarchar(4000) that is not enough. Is there a way to say NHibernate that I’m going to use longer strings?
P.S. DB is MSSQL 2005.
Thanks in advance!
Assuming
Paramis used as a constraint against a mapped property, the query will try to use the correct data type and length for the parameter, according to the mapped property. DoesParamcorrelate to a property mapped to an nvarchar(max) column? If so, have you set the data length correctly? You should set the datalength on a string column to a length over 4000 (4001 should work), if you want Nhibernate to recognize it as nvarchar(max).