Is it possible to make LinqToSql use XmlSerializer to deserialize a typed XML field to an C# object?
Currently I have the following code: (note that I had to use XElement.ToString() to use XmlSerializer)
protected static T Deserialize<T>(string xmlString) where T : class
{
var xmlSerializer = new XmlSerializer(typeof(T));
var obj = xmlSerializer.Deserialize(new StringReader(xmlString));
return (T)obj;
}
//...
{
return ATable.Select(x => Deserializer<AContentType>(x.Content.ToString()));
// x.Content is an XElement
// AContentType is a class that can be used by XmlSerializer to deserialize
// The class was generated using xsd.exe
}
If I can't make LinqToSql use XmlSerializer, can I at least make it return a string instead of XElement?
BTW. Any thoughts how to improve the Deserialize function are welcome.