Exemplo n.º 1
0
        public static IField CreateField(FieldInfo fInfo)
        {
            IFieldEdit normalField = new FieldClass();
            normalField.Name_2 = fInfo.Name;
            normalField.AliasName_2 = fInfo.AliasName;
            normalField.Type_2 = (esriFieldType)fInfo.Type;

            normalField.IsNullable_2 = fInfo.NullAble;
            normalField.Length_2 = fInfo.Length;
            normalField.Precision_2 = fInfo.Precision;

            return normalField;
        }
Exemplo n.º 2
0
        public static FieldInfo FromEsriField(IField field)
        {
            if (field == null)
                return null;

            FieldInfo fInfo = new FieldInfo();
            fInfo.Name = field.Name;
            fInfo.AliasName = field.AliasName;
            fInfo.Length = field.Length;
            fInfo.NullAble = field.IsNullable;
            fInfo.Precision = field.Precision;
            fInfo.Type = (enumFieldType)field.Type;

            return fInfo;
        }
Exemplo n.º 3
0
        public static string GetSQLFromField(FieldInfo fInfo)
        {
            if (fInfo == null)
                return null;

            string strSQL="";
            string strTypeKey = GetTypeKey(fInfo.Type);
            switch (fInfo.Type)
            {
                case enumFieldType.String:
                    if (string.IsNullOrEmpty(strTypeKey ))
                        strTypeKey = "varchar";

                    strSQL=string.Format("{0}({1}) {2}",strTypeKey,
                        fInfo.Length>0?fInfo.Length:50,fInfo.NullAble?"":"Not Null");
                    break;

                case enumFieldType.Int:
                    if (string.IsNullOrEmpty(strTypeKey))
                        strTypeKey = "Int";
                    strSQL = strTypeKey;
                    break;

                case enumFieldType.Decimal:
                    if (string.IsNullOrEmpty(strTypeKey))
                        strSQL = "numeric";
                    else
                    {
                        int fLen = fInfo.Length > 0 ? fInfo.Length : 5;
                        strSQL = string.Format("{0}({1},{2})", strTypeKey,
                           fLen,
                           fInfo.Precision > fLen ? fLen : fInfo.Precision);
                    }
                    break;

                case enumFieldType.DateTime:
                    if (string.IsNullOrEmpty(strTypeKey))
                        strTypeKey = "DateTime";

                    strSQL = strTypeKey;

                    break;

                case enumFieldType.Image:
                case enumFieldType.Binary:
                    if (string.IsNullOrEmpty(strTypeKey))
                        strTypeKey = "Image";

                    strSQL = strTypeKey;
                    break;

                default:
                    return "varchar";
            }

            return string.Format("{0} {1}",fInfo.Name, strSQL);
        }