LINQ to Enumerable
代码如下 继续阅读“基本的 LINQ 操作”
System.WeakReference<T>
代码如下 继续阅读“基本的 LINQ 操作”
cite=LINQ to SQL FAQ – XML columns in SQL
However, LINQ to SQL does not appear to support ANY translations of XML queries on XElement to SQL – this mans that the following statement :
var filtered = from t in Table where t.XmlCol.Descendants("SomeElement").Value == somevar select twill fail at runtime as the LINQ-to-SQL parser is unable to translate on our XML data column XmlCol query into an Xpath.
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.
For example:
Dim myElement as XElement = Table.XMLdata myElement.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:
Dim myElement as XElement = Table.XMLdata myElement.Value = "test" Table.XMLdata = new XElement(myElement) db.SubmitChanges()