LINQ to SQL 目前不支持包含 XElement 查询的 Expression 对象
However, LINQ to SQL does not appear to support ANY translations of XML queries on XElement to SQL – this mans that the following statement :C#
123 var filtered = from t in Tablewhere t.XmlCol.Descendants("SomeElement").Value == somevarselect t
will fail at runtime as the LINQ-to-SQL parser is unable to translate on our XML data column XmlCol query into an Xpath.
LINQ to SQL 目前不支持由 XElement 内部变化引起的记录更新
A LINQ to SQL xml datatype column is represented as an XElement. If you modify this be careful as LINQ to SQL will not spot internal changes to XElement and save them to the database.
123 Dim myElement as XElement = Table.XMLdatamyElement.Value = "test"db.SubmitChanges()
will not alter the instance XElement and so will not change the Table.XMLdata entry. The workaround for this is to write it back as a new element:
1234 Dim myElement as XElement = Table.XMLdatamyElement.Value = "test"Table.XMLdata = new XElement(myElement)db.SubmitChanges()