Пример #1
0
 /// <summary>
 /// 填充表结构字段
 /// </summary>
 /// <param name="tableField">结构字段</param>
 /// <param name="schemaDataRow">从数据库中获得的结构表行</param>
 private void FillTableSchemaField(TableField tableField, DataRow schemaDataRow)
 {
     tableField.ColumnName                      = (schemaDataRow["ColumnName"] is DBNull) ? null : (String)schemaDataRow["ColumnName"];
     tableField.ColumnOrdinal                   = (schemaDataRow["ColumnOrdinal"] is DBNull) ? null : (Int32?)schemaDataRow["ColumnOrdinal"];
     tableField.ColumnSize                      = (schemaDataRow["ColumnSize"] is DBNull) ? null : (Int32?)schemaDataRow["ColumnSize"];
     tableField.NumericPrecision                = (schemaDataRow["NumericPrecision"] is DBNull) ? null : (Int16?)schemaDataRow["NumericPrecision"];
     tableField.NumericScale                    = (schemaDataRow["NumericScale"] is DBNull) ? null : (Int16?)schemaDataRow["NumericScale"];
     tableField.IsUnique                        = (schemaDataRow["IsUnique"] is DBNull) ? null : (Boolean?)schemaDataRow["IsUnique"];
     tableField.IsKey                           = (schemaDataRow["IsKey"] is DBNull) ? null : (Boolean?)schemaDataRow["IsKey"];
     tableField.BaseServerName                  = (schemaDataRow["BaseServerName"] is DBNull) ? null : (String)schemaDataRow["BaseServerName"];
     tableField.BaseCatalogName                 = (schemaDataRow["BaseCatalogName"] is DBNull) ? null : (String)schemaDataRow["BaseCatalogName"];
     tableField.BaseColumnName                  = (schemaDataRow["BaseColumnName"] is DBNull) ? null : (String)schemaDataRow["BaseColumnName"];
     tableField.BaseSchemaName                  = (schemaDataRow["BaseSchemaName"] is DBNull) ? null : (String)schemaDataRow["BaseSchemaName"];
     tableField.BaseTableName                   = (schemaDataRow["BaseTableName"] is DBNull) ? null : (String)schemaDataRow["BaseTableName"];
     tableField.DataType                        = (schemaDataRow["DataType"] is DBNull) ? null : (Type)schemaDataRow["DataType"];
     tableField.AllowDBNull                     = (schemaDataRow["AllowDBNull"] is DBNull) ? null : (Boolean?)schemaDataRow["AllowDBNull"];
     tableField.ProviderType                    = (schemaDataRow["ProviderType"] is DBNull) ? null : (Int32?)schemaDataRow["ProviderType"];
     tableField.IsAliased                       = (schemaDataRow["IsAliased"] is DBNull) ? null : (Boolean?)schemaDataRow["IsAliased"];
     tableField.IsExpression                    = (schemaDataRow["IsExpression"] is DBNull) ? null : (Boolean?)schemaDataRow["IsExpression"];
     tableField.IsIdentity                      = (schemaDataRow["IsIdentity"] is DBNull) ? null : (Boolean?)schemaDataRow["IsIdentity"];
     tableField.IsAutoIncrement                 = (schemaDataRow["IsAutoIncrement"] is DBNull) ? null : (Boolean?)schemaDataRow["IsAutoIncrement"];
     tableField.IsRowVersion                    = (schemaDataRow["IsRowVersion"] is DBNull) ? null : (Boolean?)schemaDataRow["IsRowVersion"];
     tableField.IsHidden                        = (schemaDataRow["IsHidden"] is DBNull) ? null : (Boolean?)schemaDataRow["IsHidden"];
     tableField.IsLong                          = (schemaDataRow["IsLong"] is DBNull) ? null : (Boolean?)schemaDataRow["IsLong"];
     tableField.IsReadOnly                      = (schemaDataRow["IsReadOnly"] is DBNull) ? null : (Boolean?)schemaDataRow["IsReadOnly"];
     tableField.ProviderSpecificDataType        = (schemaDataRow["ProviderSpecificDataType"] is DBNull) ? null : (Type)schemaDataRow["ProviderSpecificDataType"];
     tableField.DataTypeName                    = (schemaDataRow["DataTypeName"] is DBNull) ? null : (String)schemaDataRow["DataTypeName"];
     tableField.XmlSchemaCollectionDatabase     = (schemaDataRow["XmlSchemaCollectionDatabase"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionDatabase"];
     tableField.XmlSchemaCollectionOwningSchema = (schemaDataRow["XmlSchemaCollectionOwningSchema"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionOwningSchema"];
     tableField.XmlSchemaCollectionName         = (schemaDataRow["XmlSchemaCollectionName"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionName"];
     tableField.UdtAssemblyQualifiedName        = (schemaDataRow["UdtAssemblyQualifiedName"] is DBNull) ? null : (String)schemaDataRow["UdtAssemblyQualifiedName"];
     tableField.NonVersionedProviderType        = (schemaDataRow["NonVersionedProviderType"] is DBNull) ? null : (Int32?)schemaDataRow["NonVersionedProviderType"];
 }
Пример #2
0
        public bool AddField(TableField Field)
        {
            foreach (TableField field in this.fields)
            {
                if (field.ColumnName.ToUpper().Trim() == Field.ColumnName.ToUpper().Trim())
                {
                    return(false);
                }
            }

            this.fields.Add(Field);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 填充表结构表
        /// </summary>
        /// <param name="baseTable">要填充的Table/View</param>
        /// <param name="schemaDataTable">从数据库中获得的结构表</param>
        private void FillSchemaTable(BaseTable baseTable, DataTable schemaDataTable)
        {
            baseTable.Fields.Clear();

            foreach (DataRow dr in schemaDataTable.Rows)
            {
                TableField tableField = new TableField();

                FillTableSchemaField(tableField, dr);

                baseTable.AddField(tableField);
            }

            if (baseTable is View)
            {
                (baseTable as View).CreateCmdText = GetObjectCreateText(baseTable.Name);
            }
        }
Пример #4
0
 /// <summary>
 /// ����ṹ�ֶ�
 /// </summary>
 /// <param name="tableField">�ṹ�ֶ�</param>
 /// <param name="schemaDataRow">�����ݿ��л�õĽṹ����</param>
 private void FillTableSchemaField(TableField tableField, DataRow schemaDataRow)
 {
     tableField.ColumnName = (schemaDataRow["ColumnName"] is DBNull) ? null : (String)schemaDataRow["ColumnName"];
     tableField.ColumnOrdinal = (schemaDataRow["ColumnOrdinal"] is DBNull) ? null : (Int32?)schemaDataRow["ColumnOrdinal"];
     tableField.ColumnSize = (schemaDataRow["ColumnSize"] is DBNull) ? null : (Int32?)schemaDataRow["ColumnSize"];
     tableField.NumericPrecision = (schemaDataRow["NumericPrecision"] is DBNull) ? null : (Int16?)schemaDataRow["NumericPrecision"];
     tableField.NumericScale = (schemaDataRow["NumericScale"] is DBNull) ? null : (Int16?)schemaDataRow["NumericScale"];
     tableField.IsUnique = (schemaDataRow["IsUnique"] is DBNull) ? null : (Boolean?)schemaDataRow["IsUnique"];
     tableField.IsKey = (schemaDataRow["IsKey"] is DBNull) ? null : (Boolean?)schemaDataRow["IsKey"];
     tableField.BaseServerName = (schemaDataRow["BaseServerName"] is DBNull) ? null : (String)schemaDataRow["BaseServerName"];
     tableField.BaseCatalogName = (schemaDataRow["BaseCatalogName"] is DBNull) ? null : (String)schemaDataRow["BaseCatalogName"];
     tableField.BaseColumnName = (schemaDataRow["BaseColumnName"] is DBNull) ? null : (String)schemaDataRow["BaseColumnName"];
     tableField.BaseSchemaName = (schemaDataRow["BaseSchemaName"] is DBNull) ? null : (String)schemaDataRow["BaseSchemaName"];
     tableField.BaseTableName = (schemaDataRow["BaseTableName"] is DBNull) ? null : (String)schemaDataRow["BaseTableName"];
     tableField.DataType = (schemaDataRow["DataType"] is DBNull) ? null : (Type)schemaDataRow["DataType"];
     tableField.AllowDBNull = (schemaDataRow["AllowDBNull"] is DBNull) ? null : (Boolean?)schemaDataRow["AllowDBNull"];
     tableField.ProviderType = (schemaDataRow["ProviderType"] is DBNull) ? null : (Int32?)schemaDataRow["ProviderType"];
     tableField.IsAliased = (schemaDataRow["IsAliased"] is DBNull) ? null : (Boolean?)schemaDataRow["IsAliased"];
     tableField.IsExpression = (schemaDataRow["IsExpression"] is DBNull) ? null : (Boolean?)schemaDataRow["IsExpression"];
     tableField.IsIdentity = (schemaDataRow["IsIdentity"] is DBNull) ? null : (Boolean?)schemaDataRow["IsIdentity"];
     tableField.IsAutoIncrement = (schemaDataRow["IsAutoIncrement"] is DBNull) ? null : (Boolean?)schemaDataRow["IsAutoIncrement"];
     tableField.IsRowVersion = (schemaDataRow["IsRowVersion"] is DBNull) ? null : (Boolean?)schemaDataRow["IsRowVersion"];
     tableField.IsHidden = (schemaDataRow["IsHidden"] is DBNull) ? null : (Boolean?)schemaDataRow["IsHidden"];
     tableField.IsLong = (schemaDataRow["IsLong"] is DBNull) ? null : (Boolean?)schemaDataRow["IsLong"];
     tableField.IsReadOnly = (schemaDataRow["IsReadOnly"] is DBNull) ? null : (Boolean?)schemaDataRow["IsReadOnly"];
     tableField.ProviderSpecificDataType = (schemaDataRow["ProviderSpecificDataType"] is DBNull) ? null : (Type)schemaDataRow["ProviderSpecificDataType"];
     tableField.DataTypeName = (schemaDataRow["DataTypeName"] is DBNull) ? null : (String)schemaDataRow["DataTypeName"];
     tableField.XmlSchemaCollectionDatabase = (schemaDataRow["XmlSchemaCollectionDatabase"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionDatabase"];
     tableField.XmlSchemaCollectionOwningSchema = (schemaDataRow["XmlSchemaCollectionOwningSchema"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionOwningSchema"];
     tableField.XmlSchemaCollectionName = (schemaDataRow["XmlSchemaCollectionName"] is DBNull) ? null : (String)schemaDataRow["XmlSchemaCollectionName"];
     tableField.UdtAssemblyQualifiedName = (schemaDataRow["UdtAssemblyQualifiedName"] is DBNull) ? null : (String)schemaDataRow["UdtAssemblyQualifiedName"];
     tableField.NonVersionedProviderType = (schemaDataRow["NonVersionedProviderType"] is DBNull) ? null : (Int32?)schemaDataRow["NonVersionedProviderType"];
 }
Пример #5
0
        /// <summary>
        /// ����ṹ��
        /// </summary>
        /// <param name="baseTable">Ҫ����Table/View</param>
        /// <param name="schemaDataTable">�����ݿ��л�õĽṹ��</param>
        private void FillSchemaTable(BaseTable baseTable, DataTable schemaDataTable)
        {
            baseTable.Fields.Clear();

            foreach (DataRow dr in schemaDataTable.Rows)
            {
                TableField tableField = new TableField();

                FillTableSchemaField(tableField, dr);

                baseTable.AddField(tableField);
            }

            if (baseTable is View)
            {
                (baseTable as View).CreateCmdText = GetObjectCreateText(baseTable.Name);
            }
        }
Пример #6
0
 public bool RemoveField(TableField Field)
 {
     return(this.fields.Remove(Field));
 }
Пример #7
0
 public bool RemoveField(TableField Field)
 {
     return this.fields.Remove(Field);
 }
Пример #8
0
        public bool AddField(TableField Field)
        {
            foreach (TableField field in this.fields)
            {
                if (field.ColumnName.ToUpper().Trim() == Field.ColumnName.ToUpper().Trim())
                {
                    return false;
                }
            }

            this.fields.Add(Field);
            return true;
        }