Export (0) Print
Expand All

DbSyncTableDescription Class

Represents the schema of a table that is included in the Tables list of a DbSyncScopeDescription object. This is used during database provisioning.

System.Object
  Microsoft.Synchronization.Data.DbSyncTableDescription

Namespace:  Microsoft.Synchronization.Data
Assembly:  Microsoft.Synchronization.Data (in Microsoft.Synchronization.Data.dll)

[SerializableAttribute]
public class DbSyncTableDescription

The DbSyncTableDescription type exposes the following members.

  NameDescription
Public methodDbSyncTableDescription()Initializes a new instance of the DbSyncTableDescription class by using default values.
Public methodDbSyncTableDescription(String)Initializes a new instance of the DbSyncTableDescription class for the specified table name.
Top

  NameDescription
Public propertyColumnsGets a list of DbSyncColumnDescription objects that represent the columns in a table.
Public propertyConstraintsGets a list of DbSyncForeignKeyConstraint objects that represent the foreign key constraints that apply to a table.
Public propertyGlobalNameGets or sets the name, including database-specific delimiters, that other nodes in a synchronization topology use to identify a table.
Public propertyIsTableMappedGets whether GlobalName and LocalName are the same.
Public propertyLocalNameGets or sets the name, including database-specific delimiters, that the local node in a synchronization topology uses to identify a table.
Public propertyNonPkColumnsGets a list of DbSyncColumnDescription objects that represent all columns in a table other than the primary key columns.
Public propertyPkColumnsGets a list of DbSyncColumnDescription objects that represent all primary key columns in a table.
Public propertyUnquotedGlobalNameGets or sets the name, not including database-specific delimiters, that other nodes in a synchronization topology use to identify a table.
Public propertyUnquotedLocalNameGets or sets the name, not including database-specific delimiters, that the local node in a synchronization topology uses to identify a table.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToStringReturns a string that represents the DbSyncTableDescription object. (Overrides Object.ToString().)
Top

The following code example describes a scope named filtered_customer, and adds three tables to the scope: Customer, CustomerContact, and NewTable. The first two tables already exist in the server database, so the GetDescriptionForTable method is used to retrieve the schema from the server database. All columns from the Customer table are included, but only two columns from the CustomerContact table are included. The NewTable table is defined by using DbSyncTableDescription and DbSyncColumnDescription objects, and then the table is created in the server database (and in the other databases that synchronize with it). To view this code in the context of a complete example, see How To: Execute Database Synchronization (SQL Server).

DbSyncScopeDescription scopeDesc = new DbSyncScopeDescription("filtered_customer");

// Definition for Customer.
DbSyncTableDescription customerDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn);
scopeDesc.Tables.Add(customerDescription);


// Definition for CustomerContact, including the list of columns to include.
Collection<string> columnsToInclude = new Collection<string>();
columnsToInclude.Add("CustomerId");
columnsToInclude.Add("PhoneType");
DbSyncTableDescription customerContactDescription =
    SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn);

scopeDesc.Tables.Add(customerContactDescription);

DbSyncTableDescription newTableDescription = new DbSyncTableDescription("Sales.NewTable");

DbSyncColumnDescription newTableIdCol = new DbSyncColumnDescription();
DbSyncColumnDescription newTableContentCol = new DbSyncColumnDescription();

newTableIdCol.UnquotedName = "NewTableId";
newTableIdCol.Type = "int";
newTableIdCol.IsPrimaryKey = true;

newTableContentCol.UnquotedName = "NewTableContent";
newTableContentCol.Type = "nvarchar";
newTableContentCol.Size = "100";
newTableContentCol.IsPrimaryKey = false;

newTableDescription.Columns.Add(newTableIdCol);
newTableDescription.Columns.Add(newTableContentCol);
scopeDesc.Tables.Add(newTableDescription);


Dim scopeDesc As New DbSyncScopeDescription("filtered_customer")

' Definition for Customer. 
Dim customerDescription As DbSyncTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.Customer", serverConn)
scopeDesc.Tables.Add(customerDescription) 


' Definition for CustomerContact, including the list of columns to include. 
Dim columnsToInclude As New Collection(Of String)()
columnsToInclude.Add("CustomerId") 
columnsToInclude.Add("PhoneType") 
Dim customerContactDescription As DbSyncTableDescription = SqlSyncDescriptionBuilder.GetDescriptionForTable("Sales.CustomerContact", columnsToInclude, serverConn)

scopeDesc.Tables.Add(customerContactDescription) 

Dim newTableDescription As New DbSyncTableDescription("Sales.NewTable")

Dim newTableIdCol As New DbSyncColumnDescription()
Dim newTableContentCol As New DbSyncColumnDescription()

newTableIdCol.UnquotedName = "NewTableId" 
newTableIdCol.Type = "int" 
newTableIdCol.IsPrimaryKey = True 

newTableContentCol.UnquotedName = "NewTableContent" 
newTableContentCol.Type = "nvarchar" 
newTableContentCol.Size = "100" 
newTableContentCol.IsPrimaryKey = False 

newTableDescription.Columns.Add(newTableIdCol) 
newTableDescription.Columns.Add(newTableContentCol) 
scopeDesc.Tables.Add(newTableDescription) 


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft