从 XmlReader 创建 XmlDataSource 的最有效方法是什么?我正在尝试使用阅读器从我的 MS-SQL 数据库中读取 XML 列,以防止对数据进行昂贵的序列化。
这是我当前的代码,似乎效率不高:
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
提前致谢!