コード例 #1
0
        void ParseColumns(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode columnNode in root.ChildNodes)
            {
                PDColumn column = new PDColumn();
                column.Model   = m;
                column.Package = package;
                column.Table   = table;
                column.ID      = columnNode.Attributes["Id"].Value;

                foreach (XmlNode node in columnNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        column.Name = node.InnerText;
                        break;

                    case "a:Code":
                        column.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        column.Comment = node.InnerText;
                        break;

                    case "a:DataType":
                        column.DataType = node.InnerText;
                        break;

                    case "a:Length":
                        column.Length = ConvertUtil.ToInt32(node.InnerText, 0);
                        break;

                    case "a:Precision":
                        column.Precision = ConvertUtil.ToInt32(node.InnerText, 0);
                        break;

                    case "a:Mandatory":
                        column.Mandatory = node.InnerText == "1" ? true : false;
                        break;

                    case "a:DefaultValue":
                        column.DefaultValue = node.InnerText;
                        break;

                    case "a:Identity":
                        column.Identity = node.InnerText == "1";
                        break;

                    default:
                        column.AddUnparsedNode(node);
                        break;
                    }
                }//end parse column

                table.AddColumn(column);
            }//end parse columns
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dbms"></param>
        /// <returns></returns>
        public static DbType PDMDataTypeToDbType(PDColumn column)
        {
            PDDbms dbms     = column.Model.DBMS;
            string dataType = column.DataType;

            ///todo:将PDM模型中不同关系数据库的数据类型转换成System.Data.DbType
            if (dbms.Code.StartsWith("MSSQLSRV"))
            {
                return(TypeUtil.SqlServerDataType2DbType(column.DataType));
            }
            if (dbms.Code.StartsWith("MYSQL"))
            {
                return(TypeUtil.MySqlDataType2DbType(column.DataType));
            }


            return(DbType.String);
        }
コード例 #3
0
        public static SOColumn ToSOColumn(PDColumn column)
        {
            SOColumn c = new SOColumn();

            c.Name         = column.Code;
            c.Comment      = string.IsNullOrEmpty(column.Comment) ? column.Name : column.Comment;
            c.PrimaryKey   = column.IsPK;
            c.ForeignKey   = column.IsFK;
            c.Identify     = column.Identity;
            c.Length       = column.Length;
            c.NativeType   = column.DataType.Split('(')[0];
            c.Nullable     = !column.Mandatory;
            c.DefaultValue = column.DefaultValue;
            c.Precision    = column.Length;
            c.Scale        = column.Precision; //pdm的精度对应数据库的小数位数
            c.DataType     = PDMDataTypeToDbType(column);

            return(c);
        }
コード例 #4
0
ファイル: PDTable.cs プロジェクト: ichoukou/Kalman.Studio
 public void AddColumn(PDColumn column)
 {
     _ColumnList.Add(column);
 }
コード例 #5
0
ファイル: PdmReader.cs プロジェクト: Leafney/Kalman.Studio
        void ParseColumns(PDModel m, PDPackage package,PDTable table,XmlNode root)
        {
            foreach (XmlNode columnNode in root.ChildNodes)
            {
                PDColumn column = new PDColumn();
                column.Model = m;
                column.Package = package;
                column.Table = table;
                column.ID = columnNode.Attributes["Id"].Value;

                foreach (XmlNode node in columnNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            column.Name = node.InnerText;
                            break;
                        case "a:Code":
                            column.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            column.Comment = node.InnerText;
                            break;
                        case "a:DataType":
                            column.DataType = node.InnerText;
                            break;
                        case "a:Length":
                            column.Length = ConvertUtil.ToInt32(node.InnerText, 0);
                            break;
                        case "a:Precision":
                            column.Precision = ConvertUtil.ToInt32(node.InnerText, 0);
                            break;
                        case "a:Mandatory":
                            column.Mandatory = node.InnerText == "1" ? true : false;
                            break;
                        case "a:DefaultValue":
                            column.DefaultValue = node.InnerText;
                            break;
                        case "a:Identity":
                            column.Identity = node.InnerText == "1";
                            break;
                        default:
                            column.AddUnparsedNode(node);
                            break;
                    }
                }//end parse column

                table.AddColumn(column);
            }//end parse columns
        }
コード例 #6
0
ファイル: PDTable.cs プロジェクト: Leafney/Kalman.Studio
 public void AddColumn(PDColumn column) { _ColumnList.Add(column); }
コード例 #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dbms"></param>
        /// <returns></returns>
        public static DbType PDMDataTypeToDbType(PDColumn column)
        {
            PDDbms dbms = column.Model.DBMS;
            string dataType = column.DataType;

            ///todo:将PDM模型中不同关系数据库的数据类型转换成System.Data.DbType
            if (dbms.Code.StartsWith("MSSQLSRV")) return TypeUtil.SqlServerDataType2DbType(column.DataType);
            if (dbms.Code.StartsWith("MYSQL")) return TypeUtil.MySqlDataType2DbType(column.DataType);


            return DbType.String;
        }
コード例 #8
0
        public static SOColumn ToSOColumn(PDColumn column)
        {
            SOColumn c = new SOColumn();

            c.Name = column.Code;
            c.Comment = string.IsNullOrEmpty(column.Comment) ? column.Name : column.Comment;
            c.PrimaryKey = column.IsPK;
            c.ForeignKey = column.IsFK;
            c.Identify = column.Identity;
            c.Length = column.Length;
            c.NativeType = column.DataType.Split('(')[0];
            c.Nullable = !column.Mandatory;
            c.DefaultValue = column.DefaultValue;
            c.Precision = column.Length;
            c.Scale = column.Precision; //pdm的精度对应数据库的小数位数
            c.DataType = PDMDataTypeToDbType(column);

            return c;
        }