We use Microsoft's LINQ to SQL for SQL Server 2005 databases. We use the XML data type in SQL Server so that we can do server side XQuery searches and so on.
When we converted our database to Oracle using the equivalent XMLTYPE and tried to use DevArt's LINQ to Oracle SQL we found that it was only possible to return the XML content as a C# String rather than a XDocument or XElement that Microsoft maps SQL Server XML types to by default.
This is a problem for us because our code is already based around the XElement type for XML SQL types.
This means that we have to make 100s of code changes in the C# code.
For example we would have to make 100s of changes like this:
Code: Select all
#if oracle
XElement x = XDocument.Parse((from p in db.MyTable
where p.Id == id
select p.Xml).SingleOrDefault()).Root;
#else
XElement x = (from p in db.MyTable
where p.Id == id
select p.Xml).SingleOrDefault();
#endif
I believe it is possible to modify the DevArt LINQ templates, we attempted to do this under guidance of support but it did not work:
We added the following line to the template:
Code: Select all
if(property.ServerDataType == "XMLTYPE") propType = "XDocument";
private string _Xml; ---> private XDocument _Xml;
partial void OnXmlChanging(string value); ---> partial void OnXmlChanging(XDocument value);
It then compiled OK.
However, when we use LINQ to retrieve the XML from the Oracle table we then get the following runtime errors:
{"Unable to cast object of type 'System.String' to type 'System.Xml.Linq.XDocument'."}
Is it possible to support Oracle XMLTYPES with this product somehow or do we need to find an alternative solution?
It would be a shame not to purchase the product because of this since it appears to work well otherwise.