I need to save a long XML string in SQL Server 2012.
Currently I hold in the EDMX and the database a string variable and a string column.
Problem is that my XML string can be very long (> 5000 characters)
What is the best practice to handle this variable (both in C# and in SQL Server)?
What are the benefits of using XML column?
I’m unsure as to the exact benefits to using the XML column, but personally, I think this makes sense to use it. Alternatively, there are other data types you can use to store 5000+ character long XML files.
You might want to look at things like text/ntext as well.
Take a look here at T-SQL data types: http://msdn.microsoft.com/en-us/library/ms187752.aspx
In terms of what is best to use with C#, essentially, any XML is just a string, but you could for example, load your XML from the database directly into XmlReader or XmlDocument, rather than getting it into a string first, and then proceeding to parse it as necessary (just food for thought!)
NOTE: From personal experience, I have built my own Entity Framework (unrelated to NHibernate or Microsoft’s Entity Framework). This allows XML as a data type in any database structure, so for example, in T-SQL, it will store objects mapped as XML to an XML data type, however in RDBMS systems where an XML type is not implemented, the Entity Framework gracefully degrades to the next nearest suitable alternative.