コード例 #1
0
        protected override SQLTableSchema InternalGetSchema()
        {
            DataTable      dataTable = _cursor.GetSchemaTable();
            SQLTableSchema schema    = new SQLTableSchema();

            if (dataTable.Rows.Count > 0)
            {
                SQLIndex index = new SQLIndex("");
                index.IsUnique = true;

                bool containsIsHidden = dataTable.Columns.Contains("IsHidden");
                int  columnIndex      = 0;
                foreach (System.Data.DataRow row in dataTable.Rows)
                {
                    string columnName = (string)row["ColumnName"];

                    object tempValue = row["IsUnique"];
                    bool   isUnique  = IsNull(tempValue) ? false : (bool)tempValue;

                    tempValue = row["IsKey"];
                    bool isKey = IsNull(tempValue) ? false : (bool)tempValue;

                    if (isUnique || isKey)
                    {
                        index.Columns.Add(new SQLIndexColumn(columnName));
                    }

                    Type dataType = _cursor.GetFieldType(columnIndex);

                    tempValue = row["ColumnSize"];
                    int length = IsNull(tempValue) ? 0 : (int)tempValue;

                    tempValue = row["NumericPrecision"];
                    int precision = IsNull(tempValue) ? 0 : Convert.ToInt32(tempValue);

                    tempValue = row["NumericScale"];
                    int scale = IsNull(tempValue) ? 0 : Convert.ToInt32(tempValue);

                    tempValue = row["IsLong"];
                    bool isLong = IsNull(tempValue) ? false : (bool)tempValue;

                    bool isHidden = false;
                    if (containsIsHidden)
                    {
                        tempValue = row["IsHidden"];
                        isHidden  = IsNull(tempValue) ? false : (bool)tempValue;
                    }

                    if (!isHidden)
                    {
                        schema.Columns.Add(new SQLColumn(columnName, new SQLDomain(dataType, length, precision, scale, isLong)));
                    }

                    columnIndex++;
                }

                if (index.Columns.Count > 0)
                {
                    schema.Indexes.Add(index);
                }
            }
            else
            {
                for (int index = 0; index < _cursor.FieldCount; index++)
                {
                    schema.Columns.Add(new SQLColumn(_cursor.GetName(index), new SQLDomain(_cursor.GetFieldType(index), 0, 0, 0, false)));
                }
            }

            return(schema);
        }
コード例 #2
0
        protected override SQLTableSchema InternalGetSchema()
        {
            DataTable      LDataTable = FCursor.GetSchemaTable();
            SQLTableSchema LSchema    = new SQLTableSchema();

            if (LDataTable.Rows.Count > 0)
            {
                SQLIndex LIndex = new SQLIndex("");
                LIndex.IsUnique = true;

                int LColumnIndex = 0;
                foreach (System.Data.DataRow LRow in LDataTable.Rows)
                {
                    string LColumnName = (string)LRow["ColumnName"];

                    object LValue    = LRow["IsUnique"];
                    bool   LIsUnique = IsNull(LValue) ? false : (bool)LValue;

                    LValue = LRow["IsKey"];
                    bool LIsKey = IsNull(LValue) ? false : (bool)LValue;

                    if (LIsUnique || LIsKey)
                    {
                        LIndex.Columns.Add(new SQLIndexColumn(LColumnName));
                    }

                    Type LDataType = FCursor.GetFieldType(LColumnIndex);

                    LValue = LRow["ColumnSize"];
                    int LLength = IsNull(LValue) ? 0 : (int)LValue;

                    LValue = LRow["NumericPrecision"];
                    int LPrecision = IsNull(LValue) ? 0 : Convert.ToInt32(LValue);

                    LValue = LRow["NumericScale"];
                    int LScale = IsNull(LValue) ? 0 : Convert.ToInt32(LValue);

                    LValue = LRow["IsLong"];
                    bool LIsLong = IsNull(LValue) ? false : (bool)LValue;

                    LValue = LRow["IsHidden"];
                    bool LIsHidden = IsNull(LValue) ? false : (bool)LValue;

                    if (!LIsHidden)
                    {
                        LSchema.Columns.Add(new SQLColumn(LColumnName, new SQLDomain(LDataType, LLength, LPrecision, LScale, LIsLong)));
                    }

                    LColumnIndex++;
                }

                if (LIndex.Columns.Count > 0)
                {
                    LSchema.Indexes.Add(LIndex);
                }
            }
            else
            {
                for (int LIndex = 0; LIndex < FCursor.FieldCount; LIndex++)
                {
                    LSchema.Columns.Add(new SQLColumn(FCursor.GetName(LIndex), new SQLDomain(FCursor.GetFieldType(LIndex), 0, 0, 0, false)));
                }
            }

            return(LSchema);
        }