TableInfoAttribute、KeyField、IgnoreField特性详解|C/S开发框架
作者:csframework|C/S框架网  发布日期:2022/01/20 15:57:00

TableInfoAttribute、KeyField、IgnoreField特性详解|C/S开发框架

命名空间

namespace CSFramework.DB

TableInfoAttribute

ORM模型的特性,用于指定该模型对应的物理表名

C# 全选
/// <summary>
    /// ORM模型的特性,用于指定该模型对应的物理表名
    /// </summary>
    public class TableInfoAttribute : Attribute
    {
        /// <summary>
        /// 表名
        /// </summary>
        public string TableName { get; set; }

        public TableInfoAttribute(string tableName)
        {
            this.TableName = tableName;
        }

    }

IgnoreField

忽略更新的字段,Insert,Update脚本不生成该字段

C# 全选
    /// <summary>
    /// 忽略更新的字段,Insert,Update脚本不生成该字段
    /// </summary>
    public class IgnoreField : Attribute { }

KeyField

主键字段

C# 全选
    /// <summary>
    /// 主键字段
    /// </summary>
    public class KeyField : Attribute { }

使用说明

C# 全选
    [TableInfoAttribute("sys_Log")]
    public class sys_Log
    {
        //标识该字段为主键
        [KeyField]
        public string GUID32 { get; set; }

        //该字段为自增字段,忽略
        [IgnoreField]
        public int isid { get; set; }

        public string DocNo { get; set; }

        public string LogUser { get; set; }

        public int OPType { get; set; }

        public DateTime LogDate { get; set; }

        public bool IsProcess { get; set; }

        //忽略的字段
        [IgnoreField]
        public string IgnoreField1 { get; set; }

        //忽略的字段
        [IgnoreField]
        public string IgnoreField2 { get; set; }
    }

TableInfoAttribute、KeyField、IgnoreField特性详解|C/S开发框架

C/S框架网|原创精神.创造价值.打造精品


扫一扫加作者微信
C/S框架网作者微信 C/S框架网|原创作品.质量保障.竭诚为您服务
上一篇 下一篇