well... everybody is interested and the right place for a patch regarding an
NH issue is the JIRA ticket.

2009/8/2 Mikael Henriksson <[email protected]>

> Found this as a patch for Oracle. I'll try to copy the behavior to MS SQL
> 2005. Not sure about Jira but I probably should add this as a patch or
> whatever when it is done? Anyone interested?
>
> case DbType.Xml:
>     //prepare OracleXmlType in ODP.NET
>     sqlType = SqlTypeFactory.GetString(0);
>     base.InitializeParameter(dbParam, name, sqlType);
>
>     //not make sure to override the OracleDbType
>     global::System.Type oracleDbTypeEnumType =
> global::System.Type.GetType("Oracle.DataAccess.Client.OracleDbType,
> Oracle.DataAccess");
>     dbParam.GetType().GetProperty("OracleDbType").SetValue(dbParam,
> oracleDbTypeEnumType.GetField("XmlType").GetValue(oracleDbTypeEnumType),
> null);
>     break;
>
>
>
> 2009/7/31 Mikael Henriksson <[email protected]>
>
>> I tried adding DbType.Xml to the 2005 Dialect but the build messed up
>> something or fluent nhibernate didn't like the rebuild.
>> What other steps are there besides RegisterColumnType(DbType.Xml, "XML");
>> ? I modified the previous code to  return new SqlType[] { new SqlXmlType()
>> };
>> Anything else I have to do?
>>
>>
>> 2009/7/31 Mikael Henriksson <[email protected]>
>>
>>> 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
>>>>> >>
>>>>> >> >>
>>>>> >
>>>>>
>>>>>
>>>>
>>>
>>
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to