J.D. Meier's Blog

Software Engineering, Project Management, and Effectiveness

Performance Guideline: Use ExcludeSchema Serialization Mode while Exchanging Typed DataSet Over Network

Performance Guideline: Use ExcludeSchema Serialization Mode while Exchanging Typed DataSet Over Network

  • Comments 1

Here's the next .NET Framework 2.0 performance guideline for review from Prashant Bansode, Bhavin Raichura, Girisha Gadikere and Claudio Caldato. 

Use ExcludeSchema Serialization Mode while Exchanging Typed DataSet Over Network

Applies to

  • .NET 2.0

What to Do
Set the Typed DataSet property SchemaSerializationMode to ExcludeSchema while transferring the typed DataSet over network for better performance.

Why
The serialization of a typed DataSet can be optimized by setting the SchemaSerializationMode property value to ExcludeSchema. When ExcludeSchema is used, the serialized payload does not contain schema information, tables, relations and constraints. This results in a smaller payload for network transfer, which provides better performance.

When
If it is required to send the typed DataSet over network, use ExcludeSchema Serialization Mode by setting the the typed DataSet property SchemaSerializationMode to ExcludeSchema.

ExcludeSchema is supported only for a typed DataSet. ExcludeSchema should only be used in cases where the schema information of the underlying typed DataTables, DataRelations and Constraints do not get modified.

How
The typed DataSet has a new property called SchemaSerializationMode in .NET Framework 2.0. Set the SchemaSerializationMode property of typed DataSet to ExcludeSchema before returning for network transfer as follows:

 ...
 typedDataSet.EnforceConstraints = false;
 typedDataSet.SchemaSerializtionMode = SchemaSerializationMode.ExcludeSchema;
 ...

Problem Example
A .NET 2.0 Windows Forms based application for Order Management, gets the list of Sales Orders by a Web Service call. The Web Service internally makes a business logic call to get the list of Sales Order in a Typed DataSet. The Web Service returns the Typed DataSet to the smart client application. The code implementation does not exclude schema information, while serializing the DataSet and therefore has a larger size. The larger content can take more time to transfer across network and have a negative impact on performance.

 ...
 //WebService Method
 public SalesOrdersTypedDataSet GetSalesDetailDataset()
 {
    ...
    SalesOrdersTypedDataSet salesOrdersDS = BusinessLogic.GetSalesOrders();
    ...              
    return salesOrdersDS;
 }
 ...

Solution Example
A .NET 2.0 Windows Forms based application for Order Management, gets the list of Sales Orders by a Web Service call. The Web Service internally makes a business logic call to get the list of Sales Order in a Typed DataSet. The Web Service returns the Typed DataSet to the smart client applicaiton. The code implementation uses SchemaSerializationMode property of the Sales Order Typed DataSet to reduce the size of the serialized content. It gives performance benefit while transferring over network:

 ...
 //WebService Method
 public SalesOrdersTypedDataSet GetSalesOrdersDataset()
 {
    ...
    SalesOrdersTypedDataSet salesOrdersDS = BusinessLogic.GetSalesOrders();
    salesOrdersDS.EnforceConstraints = false;
    salesOrdersDS.SchemaSerializationMode = SchemaSerializationMode.ExcludeSchema;
    return salesOrdersDS;
 }
 ...

Additional Resources

  • Great description of the mechanics and usage of the .NET 2.0 way of serializing TypedDataSet. Just wanted to add that the SchemaSerializationMode works for all 3 ways of serialization

    1. WebServices

    2. XML Remoting (default for remoting)

    3. Binary Remoting.

Page 1 of 1 (1 items)