I am only somewhat familiar with custom user types for NHibernate. I am a little confused as to which side of the coin a user type helps with. For example, let's say I have the following class...
Code:
public class UserAccount
{
private int _id;
private System.Xml.XmlDocument _accountData;
public UserAccount() {}
public int ID
{
get {return _id;}
set {_id = value;}
}
public System.Xml.XmlDocument AccountData
{
get {return _accountData;}
set {_accountData = value;}
}
}
OK... I also have the following DB table...
Code:
ID int
AccountData xml
where xml is the new Sql Server 2005 xml data/column type.
Now, the class System.Xml.XmlDocument actually has a property called OuterXml that returns the string representation of the XML document. This is the value that I actually want to store in the AccountData column in the database. And, when I retrieve the data from the database, I need to reconstitute the System.Xml.XmlDocument using a LoadXml method, which accepts a string representing the XML.
Maybe this is not the best way to go about it, but the fact remains that if I were not worrying about the persistence of this class, I would want to use the System.Xml.XmlDocument to store the account data because it gives me what I need from a progamming point of view. So, now, I just want to persist that property some how.
Also, I would like to use the xml data type in the DB because it provides some great ways to actually select and filter based on data buried in the xml.
Can this be done using user types? In the examples of user types that I have seen, they are usually mapping some class like MonetaryAmount to multiple columns in the DB that have "standard" data types like decimal or varchar.
Anyway, this is just a little more info and background. Thanks!
Kevin