コード例 #1
0
ファイル: PdSchemaBuilder.cs プロジェクト: minskowl/MY
        //public TableSchema CreateTableSchema(PdPDM.BaseTable table)
        //{

        //}
        //public TableSchema CreateTableSchema(PdPDM.View view)
        //{
        //    TableSchema ti = new TableSchema();
        //    ti.Alias = view.Name;
        //    ti.Name = view.DisplayName;
        //    ti.TableType = TableType.VIEW;
        //    foreach (PdPDM.ViewColumn  col in view.Columns)
        //    {
        //       if(!(col.Name.Trim().Length==0 || col.DisplayName.Trim().Length ==0 ||  col.DataType.Trim().Length==0))
        //        ti.AddColumn(GetColumnSchema(col));
        //    }


        //    return ti;
        //}
        public TableSchema CreateTableSchema(PdPDM.BaseTable tab)
        {
            TableSchema ti = new TableSchema();

            ti.Alias     = tab.Name;
            ti.Name      = tab.DisplayName;
            ti.TableType = TableType.TABLE;
            foreach (PdPDM.BaseColumn col in tab.Columns)
            {
                ColumnSchema ci = new ColumnSchema();
                ci.Alias = col.Name;
                ci.Name  = col.DisplayName;



                string netType = col.GetExtendedAttribute("NetType").ToString();
                if (netType != null && netType.Length > 0)
                {
                    ci.NetType = netType;
                }
                else
                {
                    ci.NetType = DbTypeToNeType(col.DataType);
                }

                ci.DataType = col.DataType;
                ci.Length   = col.Length;

                if (col.ClassName == "Column")
                {
                    PdPDM.Column column = (PdPDM.Column)col;
                    ci.AllowNulls      = !column.Mandatory;
                    ci.IsAutoIncrement = column.Identity;
                    ci.IsPrimaryKey    = column.Primary;
                    ci.IsForeignKey    = column.ForeignKey;
                }


                ci.HighValue = col.HighValue;
                ci.LowValue  = col.LowValue;

                ci.IsActive = Convert.ToBoolean(col.GetExtendedAttribute("IsActive"));

                ci.DefaultValue = getDefaultValue(ci.AllowNulls, col.DefaultValue, ci.NetType);
                ci.IsReadOnly   = Convert.ToBoolean(col.GetExtendedAttribute("IsReadOnly"));


                //ci.DataTypeId = (int)dr["ProviderType"];
                //ci.DefaultTestValue = ProviderInfoManager.GetInstance().GetTestDefaultById(this.dbProviderType, ci.DataTypeId);

                //ci.IsUnique = (bool)dr["IsUnique"];

                //ci.Ordinal = (int)dr["ColumnOrdinal"];


                ti.AddColumn(ci);
            }

            //foreach (PdPDM.Procedure pro in tab.Procedures)
            //    ti.AddProcedure(CreateProcedureSchema(pro));

            return(ti);
        }
コード例 #2
0
ファイル: TableSchema.cs プロジェクト: minskowl/MY
 /// <summary>
 /// Adds the specified ColumnSchema
 /// </summary>
 /// <param name="c"></param>
 public void AddColumn(ColumnSchema c)
 {
     columns[c.Name] = c;
     AddColumnInAllCollections(c);
 }