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)
OK, I’ve had it with the serializers in .NET.
All of them are lacking atleast some features that I need.
XML serializer can not handle circular references.
Soap serializer can not handle generics.
Binary serializer is decent but will crash and burn if your class schema change (this applies to all the others to).
And then we have all those WCF thingies, but they require contracts/interfaces.
So I got tired of this mess and I’ve finally rolled my own XML serializer.
My serialzier supports:
- Circular references
- Generic lists
- Error resolution
- Clean XML format
The error resolution works by raising events so that the developer can either ignore errors or resolve fields and types himself.
I have also added a default resolver that will handles missing “backing fields”
I’m using this serializer in Caramel Studio for the save file format.
So even if the model for my Caramel classes changes, you will still be able to load the files and you will only lose some settings.
The serializer is now part of my Alsing.Core project that can be found in the SVN repository at my google code site:
So what’s NOT supported then?
Currently lists will be treated in a special way, so only content of lists is serialized, any other custom state in a list will not be serialized.
I will add support for this later.
Multi dimentional arrays are not supported yet.
Work in progress:
I will make it possible to substitute types on serialization and deserialization, so that you can serialize graphs of proxy objects and then deserialize the same graph again by letting your proxy factory create the instances for you.