Take the 2-minute tour ×

I am looking for an ORM to use with .net, I need to be able to do full graph serialization to Xml on the entitys the ORM generates. My own research leads me towards using the WCF and the Entity Framework to achieve this, Is this the best option or is there a simpler way ?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Well, most ORM tools can emit standard POCO .NET classes, and most standard POCO classes lend themselves to serialization quite well. For example, LINQ-to-SQL has support for DataContractSerializer (not XmlSerializer) by setting Serialization Mode to Unidirectional. Entity Framework does the same (I don't think you need to change any settings for EF, though).

For "simpler" - well, what is the complexity? Setting up an Entity Framework (or LINQ-to-SQL) model isn't usually very tricky. Anything specific being problematic?

Note that xml serializers, by default, are tree serializers, not graph serializers. DataContractSerializer can support proper graphs, but you need to enable it (it isn't enabled by default in xml mode, since it produces very odd-looking xml).

You mention WCF; that is a communications technology; you don't mention comms in the question, so it isn't clear what you mean here. Note that "ADO.NET Data Services" is another option here, if you want REST-based data-access, but most ORMs should work OK with WCF. There are alternatives, of course.

share|improve this answer

Most O/R mappers have change tracking inside the context/session objects you use to fetch the entities. This gives problems when you pass the entity object over a wire as xml to a client, change it there and send it back: the session/context which fetched the object is long gone by then.

LLBLGen Pro has change tracking in the entities and therefore makes using entities over a wire a breeze. It comes with XML serialization/deserialization of graphs for WCF and also its own binary serialization for remoting (much faster than the default binary formatter, and also much more compact).

Disclaimer: I'm the lead developer of LLBLGen Pro.

share|improve this answer
And at least one of the upvotes comes from one of the support team ! –  Matt Jan 5 '09 at 14:54
heh :D. Thanks Matt :) –  Frans Bouma Jan 5 '09 at 15:19

DataSets must be the easiest way to serialize data to XML on the client side (see Using XML in a DataSet). But then it's obviously not an ORM library...

As far as I know, ORM libraries (like NHibernate) usually rely on the use of custom XmlSerializer (or customized WCF serialization), which may be too much work for you (or not...).

And then, full graph serialization to XML is set as a future goal for Salamanca, an open source software factory that includes an ORM library. We're still on early development stages, but any hand is welcome...

share|improve this answer

Your Answer

