TableInfoAttribute、KeyField、IgnoreField特性详解
命名空间
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; }
}
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网