DataContractSerializer: Working with class inheritence and circular references

DataContractSerializer is the default serializer used by WCF Services. Typically, we transmit data objects generated via Entity Framework or LINQ To SQL and do not get any serialization issues as the generated classes are ready to handle various serialization scenarios. Some days back, I needed to transmit my own business objects on the wire; encountered a few issues and learned how to handle them. This post will highlight two such issues that may happen when we transmit our own classes via WCF service.

  1. Dealing with inheritance hierarchies
  2. Dealing with circular references

Read the rest of this entry »