Entity Class Serialization
Object serialization to a data transport format that can pass between processes of distributed systems is
required to use EF in n - tier, service - oriented architecture (SOA). Object serialization also is required to
save object state in ViewState between postbacks of ASP.NET Web pages. .NET 3.5 supports the
following types of serializers:
1. .NET BinarySerializer , which is used to store objects in the ASP.NET Page. ViewState
property, can save the entity and its related objects on postback, then retrieve the objects during
the succeeding page load and attach them to a newly created ObjectContext . The
BinarySerializer also is used for .NET Remoting.
2. .NET XmlSerializer for SOAP Web services prior to the release of WCF with .NET 3.0. The
XmlSerializer can ’ t serialize relationships, which makes it useless for serializing
EntityType s with relationships.
3. WCF DataContractSerializer ( DCS ) for .NET 3.5 and VS 2008 services. The original DCS
version released with .NET 3.5 and VS 2008 could not serialize objects with both many:one and
one:many associations because the combination creates a cyclic relationship or cycle . A relatively
minor change in .NET 3.5 Service Pack (SP) 1 enables DCS to handle potential cycles and serialize
entire object graphs by a DataContractAttribute.IsReference=true attribute value. This
feature eliminates the need to write complex hacks to pass EntityType s with both types of
associations between tiers.
4. WCF DataContractJsonSerializer ( DCJS ) for .NET 3.5 and VS 2008 AJAX services, which
has limitations similar to the XmlSerializer . DCJS isn ’ t intended for use with EntityType s.
Using the DCJS with EntityType s throws an error due to addition of namespace prefixes to
references added by the DataContractAttribute.IsReference=true attribute value.
LINQ to SQL v1 offers serialization of only one:many (unidirectional) associations, so it doesn ’ t
preserve EDM object graphs in which any associations are bidirectional.
No comments:
Post a Comment