One of my entities in my LinqToSql model has a field of type XElement, mapped to an XML column in SQL Server.
When I do the following:
myEntity.MyXmlField.Add(new XAttribute("attribute", "value"));
...
DataContext.SubmitChanges();
The field does not get updated in the database (but other fields do). I take it that the DataContext cannot track changes made inside the XElement and thus this field is not marked as dirty and does not get updated.
Is this the correct assumption and how can I fix it?
EDIT
After reading the link that The Scrum Meister provided, it looks like
myEntity.MyXmlField = new XElement(myEntity.MyXmlField);
will solve the issue.
However this solution is quite specific to XElement (as it's easy to clone it), and involves a lot of processing if the XElement is large.
There's got to be a general way of letting the DataContext know that a field has changed.