MetaColumn
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
The MetaColumn class represents a column in a table in the underlying database. MetaColumn elements are children of MetaTable elements. Via the MetaColumn class you could take access to the following information:
- SqlType - the type of data stored in the column.
- IsNullable - indicates whether the corresponding column can have a null value.
- Length - the maximum number of digits used to represent the column contents.
- Scale - the scale of the column.
- Table - the parent table that is associated with the current column.
- IsPrimaryKey - indicates whether the column is part of the table's primary key.
- IsBackendCalculated - indicates whether the corresponding column value is calculated on the server.
- AdoType - the Ado data type for the current column. It is used for internal type mapping.
- IsBackendVersion - indicates whether the column is a backend-specific version column.
- HasDefaultValue - indicates whether the corresponding column has a default value on the server.
The following example explores the columns for each one of the tables from the metadata model:
private string GetColumns(Telerik.OpenAccess.Metadata.MetadataContainer container)
{
StringBuilder sb = new StringBuilder();
foreach (MetaTable table in container.Tables)
{
sb.AppendFormat("\nTable: {0}", table.Name);
foreach (MetaColumn column in table.Columns)
{
sb.AppendFormat("\n****Column: {0}, IsPrimaryKey: {1}, SqlType: {2}",
column.Name, column.IsPrimaryKey, column.SqlType);
}
}
return sb.ToString();
}
Private Function GetColumns(ByVal container As Telerik.OpenAccess.Metadata.MetadataContainer) _
As String
Dim sb As New StringBuilder()
For Each table As MetaTable In container.Tables
sb.AppendFormat(vbLf & "Table: {0}", table.Name)
For Each column As MetaColumn In table.Columns
sb.AppendFormat(vbLf & "****Column: {0}, IsPrimaryKey: {1}, SqlType: {2}",
column.Name, column.IsPrimaryKey, column.SqlType)
Next column
Next table
Return sb.ToString()
End Function
The following example shows a sample XML representation of a MetaTable element with two MetaColumn elements:
<orm:table name="RentalOrders">
<orm:column name="RentalOrderID" sql-type="int" nullable="false" length="0" scale="0"
primary-key="true" backend-calculated="true" ado-type="Int32" />
<orm:column name="DateProcessed" sql-type="datetime" nullable="true" length="0" scale="0"
ado-type="DateTime" />
</orm:table>