コード例 #1
0
ファイル: Column.cs プロジェクト: dstrucl/Tangenta40
        public string GetColumnSQLiteDefinitionLine(DBTableControl dbTables, ref List<ForeignKey> m_Fkey, List<string> UniqueConstraintNameList, ref string sql_DBm, SQLTable DBm_owner_Table)
        {
            SQLTable refTable = null;
            SQLTable new_ref_Table = null;
            if (obj != null)
            {
                string columnName = StaticLib.Func.GetNameFromObjectType(obj);
                this.Name = columnName;
                string sBasicType = null;
                // complex types
                string strNull;
                if (nulltype == nullTYPE.NOT_NULL)
                {
                    strNull = " NOT NULL";
                }
                else
                {
                    strNull = " NULL";
                }

                string strUNIQUE;
                if ((this.flags & Flags.UNIQUE)!=0)
                {
                    strUNIQUE = " UNIQUE ";
                }
                else
                {
                    strUNIQUE = "";
                }

                if (obj.GetType() == typeof(ID))
                {
                    ID ID = (ID)obj;
                    return Globals.LeftMargin + "'" + columnName + "' INTEGER PRIMARY KEY AUTOINCREMENT";
                }
                else if (dbTables.IsMyTable(out refTable, obj.GetType()))
                {

                    if (DBtypesFunc.Is_DBm_Type(refTable.objTable))
                    {
                        if (DBm_owner_Table == null)
                        {
                            DBm_owner_Table = this.ownerTable;
                        }
                        new_ref_Table = new SQLTable(refTable, DBm_owner_Table, dbTables.items);
                        dbTables.items.Add(new_ref_Table);

                        string new_sql_DBm = new_ref_Table.SQLitecmd_CreateTable(dbTables, UniqueConstraintNameList, ref sql_DBm, DBm_owner_Table);
                        sql_DBm += new_sql_DBm;

                        refTable = new_ref_Table;
                        this.Name = refTable.TableName;
                        int iCount = this.Name_in_language.sText_Length;
                        for (int i = 0; i < iCount; i++)
                        {
                            this.Name_in_language.sText(i,refTable.lngTableName.sText(i) + ":" + this.Name_in_language.sText(i));
                        }
                    }
                    this.Name = this.Name + "_ID";
                    string str;
                    ForeignKey fk = new ForeignKey();
                    str = Globals.LeftMargin + AddForeignKeySQLite(ref m_Fkey, refTable, ref fk) + " INTEGER " + strNull + " REFERENCES " + refTable.TableName + "(ID)" + strUNIQUE;
                    fKey = fk;
                    return str;
                }
                else
                {
                    sBasicType = DBTypes.DBtypesFunc.GetBasicTypeSQLite(obj) + strUNIQUE;
                }

                return Globals.LeftMargin + "'" + columnName + "' " + sBasicType + strNull + strUNIQUE;
            }
            else
            {
                return "!!!Object Is Null!!!";
            }
        }