Linq-to-Sql not detecting change in xml

Posted by porum on Stack Overflow See other posts from Stack Overflow or by porum
Published on 2010-03-31T03:05:00Z Indexed on 2010/03/31 3:13 UTC
Read the original article Hit count: 313

Filed under:
|

I have an xml field (Answers) in Sql Server, but when changing the content via Linq-to-Sql, the record is not flagged for updating. e.g. in Linqpad...

var profile = Profiles.FirstOrDefault(p => p.Answers != null);
profile.Answers.SetAttributeValue("date", DateTime.Now.ToString());
GetChangeSet().Dump();                            // nothing flagged
profile.Answers = new XElement(profile.Answers);  // ends up with correct xml
GetChangeSet().Dump();                            // record is flagged as changed

Any suggestions apart from assigning a clone of itself to the field or storing the xml as a string to force the update?

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about Xml