What is the most efficient way to create an XmlDataSource from an XmlReader? I'm trying to read an XML column from my MS-SQL database using the reader to prevent costy serialization of the data.
Here's my current code which doesn't seem to be really efficient:
Public Shared Function HoleDatenquelle(ByVal ConnectionString As String) As XmlDataSource
Using con As New SqlConnection(ConnectionString)
con.Open()
Using XmlDataSource As New XmlDataSource()
With XmlDataSource
Using Reader = New SqlCommand("SELECT Daten FROM tblEinstellungen WHERE Benutzer = '_System_' AND Einstellung = 'Navigation'", con).ExecuteXmlReader()
.Data = Reader.ReadOuterXml()
End Using
.ID = DateTime.Now.Ticks.ToString()
.XPath = "/Menü/*"
End With
Return XmlDataSource
End Using
End Using
End Function
Thanks in Advance!