Friday, September 11, 2009

Updating XML fields using LINQ to SQL

There is an hard to avoid issue with LINQ to SQL. That is you cannot update data on XML data fields using LINQ to SQL. This is a work around so you can update data in XML data fields using LINQ to SQL.

  • Open your DML file on Microsoft Visual Studio.

  • Drag and drop the table(s) that have the XML data field(s). (This is a new instance let the original table to be there. For example if original table name is "Employee" this might be "Employee1".)

  • Click on the data field name that has XML type data.

  • On properties box change the Type under Code Generation to String.

  • Now when ever you need to update the XML data, use the new table instance.

Please note when compiling you may get a warning saying two references for same table might to lead to a conflict. You can safely ignore it and do wise coding. :-)

Recommended Books

No comments:

Post a Comment