最近换工作,看了一下新单位的底层代码,感觉还有很多优化的空间,自己尝试着写一个orm框架,先从实体类的特性入手,直接上代码 ,工作未完成 ,随时修改代码
/// <summary> /// 表属性 /// </summary> [AttributeUsage(AttributeTargets.Class)] public class TableAttribute : Attribute { /// <summary> /// 初始化 /// </summary> /// <param name="p_TableName">名称</param> /// <param name="p_Description">描述</param> public TableAttribute(string p_TableName, string p_Description = "") { this.TableName = p_TableName; this.Description = p_Description; } /// <summary> /// 名称 /// </summary> public string TableName { get; protected set; } /// <summary> /// 描述 /// </summary> public string Description { get; protected set; } } /// <summary> /// 列属性 /// </summary> [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] public class ColumnAttribute : Attribute { /// <summary> /// 初始化 /// </summary> /// <param name="ColumnName">列名</param> /// <param name="Description">说明</param> /// <param name="Length">长度</param> /// <param name="Key">主键</param> /// <param name="IsUpdate">是否更新</param> /// <param name="IsInsert">是否写入</param> public ColumnAttribute(string ColumnName, string Description = "", int Length = 0, bool Key = false, bool = true, bool IsInsert = true) { this.ColumnName = ColumnName; this.Description = Description; this.Length = Length; this.Key = Key; this.IsUpdate = IsUpdate; this.IsInsert = IsInsert; } /// <summary> /// 列名 /// </summary> public string ColumnName { get; protected set; } /// <summary> /// 主键 /// </summary> public bool Key { get; protected set; } /// <summary> /// 长度,大小 /// </summary> public int Length { get; protected set; } /// <summary> /// 字段描述 /// </summary> public string Description { get; protected set; } /// <summary> /// 是否更新 /// </summary> public bool IsUpdate { get; protected set; } /// <summary> /// 是否写入 /// </summary> public bool IsInsert { get; protected set; }
评论列表
评论内容: