Never mind, it is interface based. I've done too much coding today Zzzz 2009/7/31 Mikael Henriksson <[email protected]>
> Do I need to update NHibernate and recompile it or can I load it > dynamically? > > > 2009/7/30 Mikael Henriksson <[email protected]> > >> Ok, I found the following code over at http://gist.github.com/47082 : >> >> using System; >> using System.Collections.Generic; >> using System.Data; >> using System.Data.Common; >> using System.Text; >> using System.Xml; >> using NHibernate.SqlTypes; >> using NHibernate.UserTypes; >> >> namespace NHibernate.Custom >> { >> public class XmlType : IUserType >> { >> public new bool Equals(object x, object y) >> { >> if (x == null || y == null) >> return false; >> >> var xdoc_x = (XmlDocument) x; >> var xdoc_y = (XmlDocument) y; >> return xdoc_y.OuterXml == xdoc_x.OuterXml; >> } >> >> public int GetHashCode(object x) >> { >> return x.GetHashCode(); >> } >> >> >> public object NullSafeGet(IDataReader rs, string[] names, object owner) >> { >> if (names.Length != 1) >> throw new InvalidOperationException("names array has more than >> one element. can't handle this!"); >> >> var document = new XmlDocument(); >> >> var val = rs[names[0]] as string; >> >> if (val != null) >> { >> document.LoadXml(val); >> return document; >> } >> >> return null; >> } >> >> public void NullSafeSet(IDbCommand cmd, object value, int index) >> { >> var parameter = (DbParameter )cmd.Parameters[index]; >> >> if(value == null) >> { >> parameter.Value = DBNull.Value; >> return; >> } >> >> parameter.Value = ((XmlDocument) value).OuterXml; >> } >> >> public object DeepCopy(object value) >> { >> >> var toCopy = value as XmlDocument; >> >> if(toCopy==null) >> return null; >> >> var copy = new XmlDocument(); >> copy.LoadXml(toCopy.OuterXml); >> return copy; >> } >> >> public object Replace(object original, object target, object owner) >> { >> throw new NotImplementedException(); >> } >> >> public object Assemble(object cached, object owner) >> { >> var str = cached as string; >> if (str != null) >> { >> var doc = new XmlDocument(); >> doc.LoadXml(str); >> return doc; >> } >> else >> { >> return null; >> } >> >> } >> >> public object Disassemble(object value) >> { >> var val = value as XmlDocument; >> if(val != null) >> { >> return val.OuterXml; >> } >> else >> { >> return null; >> } >> } >> >> public SqlType[] SqlTypes >> { >> get >> { >> return new SqlType[] { new SqlXmlStringType() }; >> } >> } >> >> public Type ReturnedType >> { >> get { return typeof(XmlDocument); } >> } >> >> public bool IsMutable >> { >> get { return true; } >> } >> } >> >> public class SqlXmlType : SqlType >> { >> public SqlXmlType() : base(DbType.Xml) >> { >> } >> } >> >> public class SqlXmlStringType : SqlType >> { >> public SqlXmlStringType() >> : base(DbType.String, 4000) >> { >> } >> } >> >> } >> >> 2009/7/30 Mikael Henriksson <[email protected]> >> >> > >> > Excuse me for being a n00b but that didn't help me much. So I need to >> create my own IUserType/IProperty for now? I have tried searching for this >> on both google and bing but I haven't had any luck yet. Any help >> appreciated! >> > >> > >> > 2009/7/29 Fabio Maulo <[email protected]> >> >> >> >> http://nhjira.koah.net/browse/NH-866 >> >> >> >> 2009/7/29 Mikael Henriksson <[email protected]> >> >>> >> >>> Hi, >> >>> >> >>> Is it possible to map the sql db type Xml to a property of type >> XDocument/XmlDocument? If it's not supported by default how do I work around >> it? >> >>> >> >>> >> >> >> >> >> >> >> >> -- >> >> Fabio Maulo >> >> >> >> >> >> >> > >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
