啊鑫
2024-07-09 0552fcc8cb73fc3021e2915129f55a42ed3f20e5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#region
 
using System;
 
#endregion
 
namespace CSFrameworkV5.Interfaces.InterfaceModels
{
    /// <summary>
    ///     字段定义实体类
    /// </summary>
    [Serializable]
    public class FieldNameDef
    {
        public FieldNameDef()
        {
            FieldName = "";
            Caption = "";
        }
 
        /// <summary>
        ///     构造器
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="caption"></param>
        /// <param name="isStringType">对应SQL脚本,字符匹配类型</param>
        public FieldNameDef(string fieldName, string caption, string fieldType)
        {
            FieldName = fieldName;
            Caption = caption;
            FieldType = fieldType;
        }
 
        /// <summary>
        ///     预设字段标题
        /// </summary>
        public string Caption { get; set; }
 
        /// <summary>
        ///     DB物理字段名
        /// </summary>
        public string FieldName { get; set; }
 
        public string FieldType { get; set; }
 
        /// <summary>
        ///     排序,1升序,2降序,对应ImageIndex的图片序号
        /// </summary>
        public int OrderBy { get; set; }
 
        public FieldNameDef Copy()
        {
            var o = new FieldNameDef();
            o.Caption = Caption;
            o.FieldName = FieldName;
            o.FieldType = FieldType;
            o.OrderBy = OrderBy;
            return o;
        }
 
        /// <summary>
        ///     拼接SQL需要加单引号的字段类型,如:varchar,datetime等
        /// </summary>
        /// <returns></returns>
        public bool IsStringType()
        {
            if (string.IsNullOrEmpty(FieldType)) return true;
 
            var stringTypes =
                ",VarChar,Char,Date,DateTime,DateTime2,NChar,NText,NVarchar,SmallDateTime,Text,Time,Timestamp,UniqueIdentifier,Xml,";
            return stringTypes.ToLower()
                .IndexOf("," + FieldType.ToLower() + ",") >= 0;
        }
    }
}