tags:

views:

114

answers:

1

Hello,

I'm having an issue with LINQ-SQL not updating an XML column. I've run in debug and all values are correct, and when checking the table data I find out that the XML has not been updated.

Also any suggested reading on DataClassesDataContext vs DataContext?

Code:

///TEST LINQ MIHAI NEW XML
protected void testLINQ()
{

    using (DataClassesDataContext db = new DataClassesDataContext())
    {
        //load le xml 
        var client =
            from row in db.Clients
            where row.ClientName == "ZZZ NEW MIHAI"
            select row;

        //for each client
        foreach (Client c in client)
        {
            XElement xml = c.ItemTreeXML;
            //if row found
            if (xml != null)
            {
                //get list of itemids referenced in xml
                var detailIds =
                    from node in xml.Descendants("Node")
                    select node;

                foreach (XElement node in detailIds)  //FOR EACH ELEMENT IN XML 
                {
                    node.Attribute("ItemType").Value = "TESTING222 !!!!";

                }
            }
            //save client record with new xml
            //tried columns below and all update except the original 
            //c.ItemTreeXML_BAK = xml; 
            //c.ItemTreeXML = xml; 
            //c.ItemTree = xml.ToString();

            try
            {
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                logError("ClientDB", "Can't update NEW MIHAI!!!" + ex.Message);
            }
        }
    }


}
A: 

Check this question/answer/comments: http://stackoverflow.com/questions/689772/689786

eglasius