DbServerSyncProvider.Schema Property

Synchronization Services - ADO.NET 1.0 SP1

Gets or sets a SyncSchema object that contains information about the table schema on the server.

Namespace: Microsoft.Synchronization.Data.Server
Assembly: Microsoft.Synchronization.Data.Server (in microsoft.synchronization.data.server.dll)

[SuppressMessageAttribute("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] 
public SyncSchema Schema { get; set; }
/** @property */
public SyncSchema get_Schema ()

/** @property */
public void set_Schema (SyncSchema value)

public function get Schema () : SyncSchema

public function set Schema (value : SyncSchema)

Property Value

A SyncSchema object that contains information about the table schema on the server.

The SyncSchema object contains the schema information for synchronization. You can manually construct this object so that the client can obtain the schema information directly without accessing the underlying database on the server side.

The following code example creates the schema for the OrderHeader and OrderDetail tables. The code first creates a schema based on a DataSet that contains only the OrderHeader table. As with the SyncAdapter, the table name must match the SyncTable name. The schema for the OrderDetail table is then added manually. This is the place to map data types if an application requires it. To view this code in the context of a complete example, see How to: Initialize the Client Database and Work with Table Schema.

DataSet orderHeaderDataSet = util.CreateDataSetFromServer();
orderHeaderDataSet.Tables[0].TableName = "OrderHeader";
this.Schema = new SyncSchema(orderHeaderDataSet);


this.Schema.Tables["OrderDetail"].Columns["OrderDetailId"].ProviderDataType = "int";
this.Schema.Tables["OrderDetail"].Columns["OrderDetailId"].AllowNull = false;

this.Schema.Tables["OrderDetail"].Columns["OrderId"].ProviderDataType = "uniqueidentifier";
this.Schema.Tables["OrderDetail"].Columns["OrderId"].RowGuid = true;
this.Schema.Tables["OrderDetail"].Columns["OrderId"].AllowNull = false;

this.Schema.Tables["OrderDetail"].Columns["Product"].ProviderDataType = "nvarchar";
this.Schema.Tables["OrderDetail"].Columns["Product"].MaxLength = 100;
this.Schema.Tables["OrderDetail"].Columns["Product"].AllowNull = false;

this.Schema.Tables["OrderDetail"].Columns["Quantity"].ProviderDataType = "int";
this.Schema.Tables["OrderDetail"].Columns["Quantity"].AllowNull = false;
//The primary key columns are passed as a string array.
string[] orderDetailPrimaryKey = new string[2];
orderDetailPrimaryKey[0] = "OrderDetailId";
orderDetailPrimaryKey[1] = "OrderId";
this.Schema.Tables["OrderDetail"].PrimaryKey = orderDetailPrimaryKey;