blob: 6e4de50c599f19e54794f86676bda48371fe5e4d [file] [log] [blame]
---
title: Data Serialization – .NET
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
All data moving out of the client cache must be serializable.
- <%=vars.product_name%> Portable Data eXchange (PDX) serialization
- `DataSerializable` interface serialization
The `DataSerializable` interface can be a good option performance-wise if the size of your objects
is small, but do not as readily support code that executes on the server, such as queries and functions.
Each of these serialization methods provides two options:
- PDXSerializable / DataSerializable for objects under your control, that is, objects you can modify to incorporate their own serialization and deserialization code
- PDXSerializer / DataSerializer for objects not under your control, that is, objects for which serialization and deserialization must be specified separately from the objects themselves.
For .NET, a reflection-based autoserialization option is also available, but it is limited to cases in which the objects being serialized (a) contain no transient state and (b) are composed only of primitive types.
# .NET Data Serialization Options
The .NET client API provides an option not available to the C++ API, as .NET objects are capable of reflection.
The recommended choice is iPDXSerializable.
With reflection-based autoserialization, built-in .NET types are serialized automatically into the
cache and can be retrieved by <%=vars.product_name%> servers and other <%=vars.product_name%> clients. For domain
objects that are not simple types, you have three <%=vars.product_name%> serialization options.
- The simplest option is to use automatic serialization by registering the <%=vars.product_name%> .NET PDX
reflection-based autoserializer in your application. When you have this registered, <%=vars.product_name%> uses it
for all domain objects that are not custom serialized.
- You can custom serialize your objects by implementing the <%=vars.product_name%> `IDataSerializable` .NET interface.
- You also have the option of using default .NET serialization, but you cannot use it unless you also
use helper classes. The helper classes you must use are `CacheableObject` and `CacheableObjectXml`.