How do i retrive data of xml column using SafeDataReader

How do i retrive data of xml column using SafeDataReader

Old forum URL: forums.lhotka.net/forums/t/4703.aspx


C#Master posted on Thursday, April 17, 2008

We are using MSSql server 2005 and we have a column in database table with xml data type.  We want to read this xml column data using CSLA .Net framework's SafeDataReader. But there is not any method to get xml data from reader like GetString(), GetInt32()..

In this xml column we do have xml data just like this

<Lang>

   <DE>

            <Description> Some German text </Description>

   </DE>

   <EN>

            <Description> Some English text </Description>

   </EN>

      ......

      .....

</Lang>

Does CSLA.Net provides method to retrive xml data? or  Can we use GetString() or GetBytes() of SafeDataReader? If there is any another way to solve above problem then please suggest.

 

Patrick.Roeper replied on Thursday, April 17, 2008

I use GetString().

Here is an example where you can load the xml data and feed it into an XDocument (.NET 3.5)...

string _xmlDataString;
XDocument _xmlData;

_xmlDataString = dr.GetString("OverrideData");

if(string.IsNullOrEmpty(_xmlDataString) == false)
    _xmlData = XDocument.Parse(_xmlDataString);

Copyright (c) Marimer LLC