An early alpha of Linq to SqlXml is now available on github: https://github.com/calyptus/linq-to-sqlxml
There is no documentation nor setup scripts so you’re on your own if you try it.
If you get it to run, be sure to add all indexes to the xml field – primary , secondary – path , secondary – value , secondary – property
I’m hacking along on my Document DB emulator ontop of Sql Server XML columns.
I have some decent Linq support in place now.
The following query:
var query = from order in orders
//must have status shipped
where order.Status >= OrderStatus.Shipped
//must contain foo or bar products
where order.OrderDetails.Any(d => d.ProductNo == "Foo" || d.ProductNo == "Bar")
//must have an order total > 100
where order.OrderDetails.Sum(d => d.ItemPrice * d.Quantity) > 100
will yield the following Sql + XQuery to the Sql Server:
where CollectionName = 'Order' and
--must have an order total > 100
for $A in OrderDetails/object/state
return ($A/ItemPrice * $A/Quantity)) > xs:decimal(100))]') = 1) and
--must contain foo or bar products
(documentdata.exist('/object/state[OrderDetails/object/state[((ProductNo = "Foo") or
(ProductNo = "Bar"))]]') = 1) and
--must have status shipped
(documentdata.exist('/object/state[(Status >= xs:int(2))]') = 1)