Пример #1
0
        protected virtual string GetHBMCSType(HField field)
        {
            string f1 = "";

            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "String";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int";
                }
                else
                {
                    f1 = "Decimal";
                }
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime";
            }

            return(f1);
        }
Пример #2
0
        protected override string GetCSType(HField field)
        {
            string f1 = "";

            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "string ";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int? ";
                }
                else
                {
                    f1 = "decimal? ";
                }
            }
            else if (field.Type == HFieldType.FLOAT)
            {
                f1 = "decimal? ";
            }
            else if (field.Type == HFieldType.INT)
            {
                f1 = "int? ";
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime? ";
            }
            else if (field.Type == HFieldType.BINARY)
            {
                f1 = "Byte[] ";
            }

            return(f1);
        }
Пример #3
0
        protected override string GetHBMCSType(HField field)
        {
            string f1 = "";

            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "String";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int";
                }
                else
                {
                    f1 = "Decimal";
                }
            }
            else if (field.Type == HFieldType.FLOAT)
            {
                f1 = "Decimal";
            }
            else if (field.Type == HFieldType.INT)
            {
                f1 = "int";
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime";
            }
            else if (field.Type == HFieldType.BINARY)
            {
                f1 = "BinaryBlob";
            }

            return(f1);
        }
Пример #4
0
        protected virtual string GetHBMCSType(HField field)
        {
            string f1 = "";
            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "String";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int";
                }
                else
                {
                    f1 = "Decimal";
                }
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime";
            }

            return f1;
        }
Пример #5
0
        protected virtual void BuildEntity(List <HField> m_Datas, HTable table, string rootFolder)
        {
            string templateString = HOther.ReadTemplate(m_TemplatePath, "entity.cs");

            templateString = templateString.Replace("{||ClassName||}", table.ClassName);

            templateString = templateString.Replace("{||CnName||}", table.CHName);

            HField fieldPK = m_Datas[0];

            templateString = templateString.Replace("{||m_ID||}", "m_" + fieldPK.ENName);
            templateString = templateString.Replace("{||ID||}", fieldPK.ENName);

            StringBuilder sb = new StringBuilder();

            //FieldListPrivate
            foreach (HField field in m_Datas)
            {
                //protected decimal m_ID;

                //固定第一个字段是主键
                if (field == m_Datas[0])
                {
                    sb.Append("private " + " decimal m_" + field.ENName + ";" + Environment.NewLine);
                }
                else
                {
                    string f1 = GetCSType(field);
                    sb.Append("private " + f1 + " m_" + field.ENName + ";" + Environment.NewLine);
                }
            }

            templateString = templateString.Replace("{||FieldListPrivate||}", sb.ToString());


            //FieldListInit
            sb = new StringBuilder();
            foreach (HField field in m_Datas)
            {
                //m_DATASET_ID = null;

                //固定第一个字段是主键
                if (field == m_Datas[0])
                {
                    sb.Append("m_" + field.ENName + "=0;" + Environment.NewLine);
                }
                else
                {
                    sb.Append("m_" + field.ENName + "=null;" + Environment.NewLine);
                }
            }

            templateString = templateString.Replace("{||FieldListInit||}", sb.ToString());

            //FieldListPublic
            sb = new StringBuilder();
            foreach (HField field in m_Datas)
            {
                sb.Append(@"/// <summary>" + Environment.NewLine);
                sb.Append(@"/// " + field.CHName + Environment.NewLine);
                sb.Append(@"/// </summary>	"+ Environment.NewLine);

                //固定第一个字段是主键
                if (field == m_Datas[0])
                {
                    sb.Append(@"public virtual decimal " + field.ENName + Environment.NewLine);
                    sb.Append(@"{" + Environment.NewLine);
                    sb.Append(@"get { return m_" + field.ENName + "; }" + Environment.NewLine);
                    sb.Append(@"set { m_IsChanged |= (m_" + field.ENName + " != value); m_" + field.ENName + " = value; }" + Environment.NewLine);
                    sb.Append(@"}" + Environment.NewLine);
                }
                else
                {
                    if (field.Type == HFieldType.NVARCHAR2)
                    {
                        sb.Append(@"public virtual string " + field.ENName + Environment.NewLine);
                        sb.Append(@"{" + Environment.NewLine);
                        sb.Append(@"get { return m_" + field.ENName + "; }" + Environment.NewLine);
                        sb.Append(@"set	" + Environment.NewLine);
                        sb.Append(@"{" + Environment.NewLine);
                        sb.Append(@"if ( value != null)" + Environment.NewLine);
                        if (field.Length > 0)
                        {
                            sb.Append(@"if( value.Length > " + field.Length + ")" + Environment.NewLine);
                            sb.Append("throw new ArgumentOutOfRangeException(\"Invalid value for " + field.ENName + "\", value, value.ToString());" + Environment.NewLine);
                        }
                        sb.Append(@"m_IsChanged |= (m_" + field.ENName + " != value); m_" + field.ENName + " = value;" + Environment.NewLine);
                        sb.Append(@"}" + Environment.NewLine);
                        sb.Append(@"}" + Environment.NewLine);
                    }
                    else
                    {
                        string f1 = GetCSType(field);
                        sb.Append(@"public virtual " + f1 + " " + field.ENName + Environment.NewLine);
                        sb.Append(@"{" + Environment.NewLine);
                        sb.Append(@"get { return m_" + field.ENName + "; }" + Environment.NewLine);
                        sb.Append(@"set { m_IsChanged |= (m_" + field.ENName + " != value); m_" + field.ENName + " = value; }" + Environment.NewLine);
                        sb.Append(@"}" + Environment.NewLine);
                    }
                }
            }

            templateString = templateString.Replace("{||FieldListPublic||}", sb.ToString());

            HOther.SaveStringToFile(templateString, rootFolder + "\\" + table.ClassName + ".cs");
        }
Пример #6
0
        protected override string GetCSType(HField field)
        {
            string f1 = "";
            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "string ";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int? ";
                }
                else
                {
                    f1 = "decimal? ";
                }
            }
            else if (field.Type == HFieldType.FLOAT)
            {
                f1 = "decimal? ";
            }
            else if (field.Type == HFieldType.INT)
            {
                f1 = "int? ";
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime? ";
            }
            else if (field.Type == HFieldType.BINARY)
            {
                f1 = "Byte[] ";
            }

            return f1;
        }
Пример #7
0
        protected override string GetHBMCSType(HField field)
        {
            string f1 = "";
            if (field.Type == HFieldType.NVARCHAR2 || field.Type == HFieldType.CLOB)
            {
                f1 = "String";
            }
            else if (field.Type == HFieldType.NUMBER)
            {
                //通过长度是否大于0,判断是整数还是小数
                if (field.Length > 0)
                {
                    f1 = "int";
                }
                else
                {
                    f1 = "Decimal";
                }
            }
            else if (field.Type == HFieldType.FLOAT)
            {
                f1 = "Decimal";
            }
            else if (field.Type == HFieldType.INT)
            {
                f1 = "int";
            }
            else if (field.Type == HFieldType.DATE)
            {
                f1 = "DateTime";
            }
            else if (field.Type == HFieldType.BINARY)
            {
                f1 = "BinaryBlob";
            }

            return f1;
        }