As far as I know, NH does not support that particular datatype. It's only me guessing, but I think that MSSQL uses standard ntext column, so writing a user type to handle this will be quite simple:
Code:
public class XmlDocumentUserType : UserTypeBase
{
public XmlDocumentUserType()
{
}
#region UserTypeBase Members
public override object NullSafeGet(IDataReader rs, string[] names, object owner)
{
object xmlDocument = rs[names[0]];
if(xmlDocument == null || !(xmlDocument is string))
return new XmlDocument();
string xml = xmlDocument as string;
XmlDocument effectiveXmlDocument = new XmlDocument();
effectiveXmlDocument.LoadXml(xml);
return effectiveXmlDocument;
}
public override void NullSafeSet(IDbCommand cmd, object value, int index)
{
XmlDocument xmlDocument = value as XmlDocument;
(cmd.Parameters[index] as IDataParameter).Value = xmlDocument.InnerXml;
}
public override object DeepCopy(object value)
{
return (value as XmlDocument).Clone() as XmlDocument;
}
public override SqlType[] SqlTypes
{
get { return new SqlType[] { new StringClobSqlType() }; }
}
public override Type ReturnedType
{
get { return typeof(XmlDocument); }
}
#endregion
}
public abstract class UserTypeBase : IUserType
{
public UserTypeBase()
{
}
#region IUserTypeMembers
public abstract object NullSafeGet(IDataReader rs, string[] names, object owner);
public abstract void NullSafeSet(IDbCommand cmd, object value, int index);
public abstract object DeepCopy(object value);
public abstract SqlType[] SqlTypes
{ get; }
public abstract Type ReturnedType
{ get; }
public virtual bool IsMutable
{
get { return false; }
}
public virtual new bool Equals(object x, object y)
{
if(x != null)
return x.Equals(y);
return y == null;
}
#endregion
}
[/code]