I'm building an ASP.NET web application using NHibernate and a legacy database. In that database are fields of HTML stored as VARBINARY(MAX). The existing queries cast that data using CONVERT(VARCHAR(MAX), mainText). How can I do the same using NHibernate's HBM mapping?
A:
Well, if all else fails remember your class can support this.
Psuedo Code:
public class MyPOCO {
public virtual byte[] myHTMLByteArray { get; set; }
public string myHTML {
get {
if(myHTMLByteArray != null) {
return Encoding.ASCII.GetString(myHTMLByteArray);
}
return null;
}
set {
myHTMLByteArray = Encoding.ASCII.GetBytes(value);
}
}
Wayne
2009-12-03 02:08:54
Very good point. I'm an NHibernate noob so I wasn't sure if I would do that or let some setting in the mapping handle it.
Mattio
2009-12-03 02:12:36
Don't forget to mark this as an answer if you get no other responses
Wayne
2009-12-07 13:23:10